AE: Hide object after random time
I'm not sure what the valueAtTime function is trying to achieve. That takes the value of the property at the given time. In the script you wrote it would sample the value of the opacity at a point a random number of seconds in the past, some time between the current time and maxOffset seconds ago. Unless the opacity changes during that time it won't do anything at all.

Expressions are Javascript, so you can use all the Javascript language elements, including if and else. Thus:

maxOffset = 20;
minOffset = 1;
seedRandom(index,timeless=true);
if (time&gt;random(minOffset, maxOffset)){0}else{value}


This will turn off the layer at some time between 1 and 20 seconds for each layer. If the opacity channel is already animated it will use the animated value up until the time it turns off. To change this so that it is 100% on until it turns off, substitute {100} for {value} in the last line