I am writing a script, that triggers when the player steps on something. I set this up to test if it would work.
local touching = false
script.Parent.Trigger.Touched:connect(function(hit)
if not touching then
print("Touched")
touching = true
end
end)
script.Parent.Trigger.TouchEnded:connect(function(hit)
if touching then
print("TouchEnded")
touching = false
end
end)
As a player walks on it, it triggers it multiple times EG, my output window TouchEnded Touched TouchEnded Touched TouchEnded Touched TouchEnded
How can I prevent this from happening?

1 comment
On touchended you set the variable back to false, so it can run again:o