✓ Accepted answer
If you don't want to sound to be played locally to the player, then use a ServerScript.
local debounce = false
script.Parent.Touched:connect(function(hit1)
if not debounce then
debounce = true
script.Parent.Sound:Play()
wait(3)
debounce = false
end
end)
Let me just run through quickly on what you did wrong.
local debounce = false
script.Parent.Touched:connect(function(hit1)
if debounce == false then
script.Parent.Sound:Play()
debounce = true
end
end)
Here, you placed debounce = true and debounce = false in the wrong place.
Btw, idk why you put hit1 in the parenthesis. Unless you're trying to identify that it's a player, I suggest that you do this:
local debounce = false
script.Parent.Touched:connect(function(hit1)
local character = hit1.Parent
if not debounce then
debounce = true
if character and character:findFirstChild("Humanoid") then
script.Parent.Sound:Play()
end
wait(3)
debounce = false
end
end)
What that does is that it looks for "Humanoid" in the character.
Hope this helps!
EDIT(because asked):
local debounce = false
script.Parent.Touched:connect(function(hit1)
local character = hit1.Parent
if not debounce then
debounce = true
if character and character:findFirstChild("Humanoid") then
script.Parent.Sound:Play()
end
wait(3)
debounce = false
end
end)
script.Parent.TouchEnded:connect(function()
end)
4 comments
how do i make it so at line 10 it has to wait until the player is not touching the part?
added an extra part because you asked, try that
added an extra part because you asked, try that!
had to manipulate a bit, but eventually worked. thanks! i found out the part that they had to touch first was too small. so i had to make another one that is bigger