Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cooldown with debounce making the attack on infinte cooldown how do i make it doing normal cooldown?

Asked by 2 years ago

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)`

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago

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

0
the brackets after connect are just information that is passed into the other script - it doesnt run the code in the brackets * just a thing to add! sne_123456 439 — 2y
Ad

Answer this question