So we have a Knife script, That plays an animation when you click. But you can spam click the knife, and it just glitches it out? How could we add a delay or debounce in this to stop the animation from running too fast? Thanks. Server Script:
game.ReplicatedStorage.ShankIdle.OnServerEvent:Connect(function(player) local idleanime = Instance.new("Animation") idleanime.AnimationId = "rbxassetid://3789083756" local hum = player.Character.Humanoid local idleloader = hum:LoadAnimation(idleanime) local sound1 = Instance.new("Sound", hum.Parent) sound1.SoundId = "rbxassetid://3688156764" idleloader:Play() sound1:Play() print("Equipped") end) game.ReplicatedStorage.Shank.OnServerEvent:Connect(function(player) local idleanime = Instance.new("Animation") idleanime.AnimationId = "rbxassetid://3789083756" local hum = player.Character.Humanoid local idleloader = hum:LoadAnimation(idleanime) idleloader:Stop() local anime = Instance.new("Animation") anime.AnimationId = "rbxassetid://3789143130" local hum = player.Character.Humanoid local loader = hum:LoadAnimation(anime) loader:Play() wait(0.24) idleloader:Play() print("Shanked") wait(0.5) end) game.ReplicatedStorage.QuitShankIdle.OnServerEvent:Connect(function(player) local idleanime = Instance.new("Animation") idleanime.AnimationId = "rbxassetid://3789083756" local hum = player.Character.Humanoid local idleloader = hum:LoadAnimation(idleanime) idleloader:Stop() print("Unequipped") end)
99% sure this is a troll :/ anyway
Add a debounce dude its really easy
local db = false game.ReplicatedStorage.ShankIdle.OnServerEvent:Connect(function(player) if not db then db = true local idleanime = Instance.new("Animation") idleanime.AnimationId = "rbxassetid://3789083756" local hum = player.Character.Humanoid local idleloader = hum:LoadAnimation(idleanime) local sound1 = Instance.new("Sound", hum.Parent) sound1.SoundId = "rbxassetid://3688156764" idleloader:Play() sound1:Play() print("Equipped") wait (1) -- this can be however u want db = false end) game.ReplicatedStorage.Shank.OnServerEvent:Connect(function(player) local idleanime = Instance.new("Animation") idleanime.AnimationId = "rbxassetid://3789083756" local hum = player.Character.Humanoid local idleloader = hum:LoadAnimation(idleanime) idleloader:Stop() local anime = Instance.new("Animation") anime.AnimationId = "rbxassetid://3789143130" local hum = player.Character.Humanoid local loader = hum:LoadAnimation(anime) loader:Play() wait(0.24) idleloader:Play() print("Shanked") wait(0.5) end) game.ReplicatedStorage.QuitShankIdle.OnServerEvent:Connect(function(player) local idleanime = Instance.new("Animation") idleanime.AnimationId = "rbxassetid://3789083756" local hum = player.Character.Humanoid local idleloader = hum:LoadAnimation(idleanime) idleloader:Stop() print("Unequipped") end)