Sensing when a player enters and leaves an area

How would I make code that senses when a player goes in a certain area and when they leave then run a function for both of them.

You can use region3’s for this.

https://developer.roblox.com/en-us/api-reference/datatype/Region3

task.wait(0.75) serves absolutely no purpose in this context.

You quite literally just before got the object value and all you’re doing is waiting 3/4 of a second for no reason. This is also not a good use for ObjectValues and the use case of RenderStepped feels unecessary for something that doesn’t need instant updates.

1 Like

You can literally just put in CharacterScript instead of PlayerScript to ensure that the character is there.

This is a bad practise.