I'm trying to make a sliding door that moves and plays a sound, but if you're in the trigger it'll play the sound repeatedly and the door closes slowly, and it's being very annoying.
local tweenService = game:GetService("TweenService")
local clickDetector = script.Parent.Parent.Trigger
local seconds = 4.6
debounce = true
clickDetector.Touched:Connect(function()
if debounce == true then
debounce = false
end
script.Parent.Sound:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = CFrame.new(216.762, 40.341, -192.229)}):Play()
wait(6.6)
script.Parent.Sound:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = CFrame.new(216.762, 31.888, -192.229)}):Play()
debounce = true
end)
Thank you if you can help me!

2 comments
ClickDetectors have an event called MouseClick, not touched.
I know, I was too lazy to change it