I'm making a police-criminal game like Jailbreak, and I'm making the part where when you escape it prompts you with an escape GUI to let you know.
The problem is, the event's running even if I don't touch the part where you escape
LocalScript in The GUI text label:
local Player = game:GetService("Players").LocalPlayer local Prisoner = game.Teams.Prisoners game.Workspace.CrimWall.Touched:Connect(function() if Player.Team == Prisoner then script.Parent.Parent.Visible = true script.Parent.Visible = true wait(5) script.Parent.Parent.Visible = false script.Parent.Visible = false end end)
NOTE THAT: THE REASON ISN'T BECAUSE IT'S TOUCHING SOMETHING ELSE, THE GUI COMES WHEN YOU PASS A POINT, BUT NOTHING IS AT THAT POINT, ITS NOT EVEN ANYTHING UNIONED, AND THE GUI IS COMING UP
Check if the touching instance is within the player's character hierarchy.
local Player = game:GetService("Players").LocalPlayer local Prisoner = game:GetService("Teams"):WaitForChild("Prisoners") workspace.CrimWall.Touched:Connect(function(hit) if hit and Player.Character and hit:IsDescendantOf(Player.Character) then if Player.Team == Prisoner then script.Parent.Parent.Visible = true script.Parent.Visible = true wait(5) script.Parent.Parent.Visible = false script.Parent.Visible = false end end end)