I am trying to make a Gui appear when the player enters the part and the Gui disappear when the player leaves the part. What’s the best way to detect when the player enters or leaves a part? I was thinking about using RunService and GetPartsInPart but I was wondering if there is a more efficient way of going about this. Thanks in advance!
I saw a really good tutorial on YouTube about this but I forgot the details, but you could search up something about music playing inside an area. One of the videos made it so that when you were inside the part, (the part was an invisible large space), music would play and when you exited it would stop, if you find that same tutorial you could use its script that it used to call the function and start off from there.
You can either use :Touched and have a part on the inside and outside, or use Magnitude
Example code using Touched Event:
grasslands.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local target = players:GetPlayerFromCharacter(char)
rem:FireClient(target)
end
end)
Then you would just make a small box on the outside that would “detect” when the player leaves the part using another Touched Event, or just have the script only run if the Touched event is being fired, using a while loop and a variable.
Yeah, good idea real, and when you exit (using a similar method,) you could just make the gui disappear.
Oh you already said something similar at the end nvm