If I use while true do, wouldn't it create lag for unnecessary checking every-time? Can someone point me in the right direction? I just need to know what I should do from this point on.
I don't believe there's an event for this, but you can use a loop and if creating a new thread is necessary, coroutines. You can use magnitude to check the distance between two specified parts. For example:
local base = workspace.base local part = workspace.part coroutine.resume(coroutine.create(function() while wait(1) do print (part.Position - base.Position).magnitude end end)) print("bork")
You can make an invisible non can collide-able cylinder/sphere and when a player touches it with the touched event you can change a variable to true. When the player leaves the range of nearness (invisible cylinder) you can use the touchended event and change a variable to false. Ex
--Put this script in an invisible non can collideable sphere that surrounds the object that you want to know if the player is near PlayerIsNear = false script.Parent.Touched:connect(function() PlayerIsNear = true end) script.Parent.Touchended:connect(function() PlayerIsNear = false end) if PlayerIsNear == true then --Do whatever you want here
This creates a lot less lag then a loop
There isn't an event, but if you want an alternative method, you can use magnitudes to detect how close the player is to an object. From there you can determine what you want to do with the script. I used this to create a type of radar/ way to find players near you.