I tried making a cooldown with debounce but when i use the move i cant use it again after the cooldown time passed
local player = game.Players.LocalPlayer local service = game:GetService("UserInputService") local sound = Instance.new("Sound") local rp = game:GetService("ReplicatedStorage") local Texas = rp:WaitForChild("Texas") local debounce = false local cooldown = 10
sound.SoundId = "rbxassetid://3545356912" sound.Parent = script.Parent sound.Volume = 0.3
service.InputBegan:Connect(function(input, isTyping) if isTyping then return elseif input.KeyCode == Enum.KeyCode.E then if debounce == false then debounce = true
local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://7491517614" sound:Play() player.Character.Humanoid:LoadAnimation(anim) :Play() wait(0.2) local HumanRoot = player.Character.HumanoidRootPart script.SmashEvent:FireServer(HumanRoot) Texas:FireServer() end end
end)
Texas.OnClientEvent:Connect(function() wait(cooldown) debounce = false end)`
debounce on different scripts are different, because no script share the same variable, you should disable debounce on the server script (after Texas:FireServer()
)
Below the Texas:FireServer()
code, put wait(cooldown) debounce = false
, and delete the code Texas.OnClientEvent:Connect(function() wait(cooldown) debounce = false end)
because it's wrong