Touch script repeating itself

hello!
I made a touch script.
Whenever my character touches the part it plays the sound and repeats the function
I want the script to make it so if I touch it, it will work once and not repeat it self whenever my character standing still in it.

here’s My script:

script.Parent.Touched:Connect(function()

workspace.Failed:Play()
end)
2 Likes

Add a debounce:

local debounce = false
script.Parent.Touched:Connect(function()
if not debounce then
debounce = true
workspace.Failed:Play()
end
end)
4 Likes

thanks for the assistance appreciate it