I want to prevent players from spamming the whistle key bind.
local Player = script.Parent
local function playSound()
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120675904"
sound.Parent = game.Workspace
sound:Play()
end
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.T then
playSound()
end
end)
local Player = script.Parent
local function playSound()
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9120675904"
sound.Parent = game.Workspace
sound:Play()
end
local onCooldown = false
local cooldownTime = 2
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.T and not onCooldown then
onCooldown = true
playSound()
task.delay(cooldownTime, function()
onCooldown = false
end)
end
end)
Thats what debouncing looks like OP, but make sure to also add a sound.Ended:Wait() event instead of using the cooldowntime thing that fusionet has wrote. As it’ll be accurate.