As you can see i’m having this problem that the player still pressing the button, how can i avoid this?
Here’s the script
don’t tell me i chose wrong section again
Implement a debounce
local OnPart = false
part.Touched:Connect(function()
if not OnPart then OnPart = true end
--code
end)
part.TouchEnded:Connect(function()
OnPart = false
--code
end)
Also please post your code with text and not via images.
So what I think the problem is, is that you’re not checking for a player on the onTouched event. So whenever it goes down, it is probably detecting the other part under the one with the touched event.
Try running this code in the part that you need, and screenshot the output.
local part = script.Parent
local sound = script.Parent.Sound
part.Touched:Connect(function(hit)
print(hit.Name)
end)
part.TouchEnded:Connect(function(hit)
print(hit.Name)
end)
I just fixed the problem! So thank you for the tip!