For my horror game, I've made a moving door with a sound that is connected with a button, but the sound plays again every time you click the button with no cooldown. I have tried many ways to add a cooldown but none of them work for me.
local ClickDetector = script.Parent.ClickDetector
local Door = script.Parent.Parent.Door
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
2,
Enum.EasingStyle.Back,
Enum.EasingDirection.Out,
0,
true,
0
)
local Goal =
{
Position = Vector3.new(Door.Position.X - 4, Door.Position.Y - 0.5,Door.Position.Z - 1.7)
}
local MoveDoor = TweenService:Create(Door, Info, Goal)
ClickDetector.MouseClick:Connect(function()
MoveDoor:Play()
script.RustyDoor:Play()
end)
