Temporarily invisible roof

I wish to make it so when a player walks under a roof the roof will go invisible and when they go out from under the roof it goes back to being visible, how would I go about doing this effectively. I have tried to use the touched event but I had problems with detecting when the player went out from the roof.

1 Like

I would probably do it like this:

  1. In a LocalScript, connect to the Heartbeat event of RunService
  2. Each heartbeat, raycast from the player’s character to the camera.
  3. If you hit something, and you want that something to be able to dissapear (I suggest tagging those objects with CollectionService), then change its Transparency. You can use TweenService to animate it.
  4. (edit) Keep track of the last-hit object. If you don’t hit it on the following frame, reset its Transparency to normal.
4 Likes

I would use distance, plus this way you can create a fading effect

1 Like

Use a touched event on the player’s humanoidrootpart. Make the part invisible in a localscript when the touch starts and visible when the touch ends. This will be the easiest and should work well.

1 Like

I will definitely be trying this. Thank you.