Tool W/ Cooldown And Damage

(I am a complete amateur when it comes to scripting, so my apologies if this is an obvious thing.)

I’ve been trying to make a weapon with Debounce, Damage, and Animations for a while now.
But whenever I try to make debounce I can’t get it to work.

Does anyone know to make Debounce/Cooldown in a tool with damage?

Is there a part of a script that you have an issue with? Because you can’t ask people to write a full script for you.

These may help you

3 Likes

Yes, it was adding it to a tool script. I will try this video though! Tysm!

If those don’t help you or you need help understanding let me know.

If you want to make a cooldown, you could do this, if you want to make it only usable one time per player, you could do this:
local cooldowns = {}
local cooldownTime = 30

local function onActivated(mouse)
local player = game.Players:GetPlayerFromCharacter(mouse.Parent)
if cooldowns[player] and cooldowns[player] > tick() then
print(“Cooldown not ready”)
return
end
cooldowns[player] = tick() + cooldownTime
print(“Activated”)
end

script.Parent.Activated:Connect(onActivated)

If you want to make it so it is only usable X amount of times per player, you could do this:
local cooldowns = {}
local cooldownTime = 30
local maxCooldowns = 3

local function onActivated(mouse)
if cooldowns[player] and cooldowns[player] > maxCooldowns then
print(“Cooldown not ready”)
return
end
cooldowns[player] = cooldowns[player] + 1
delay(cooldownTime, function()
cooldowns[player] = cooldowns[player] - 1
end)
print(“Activated”)
end

script.Parent.Activated:Connect(onActivated)

You didn’t really help them understand as they are new to scripting, you just wrote it for them

Took a bit of trial and error, but i figured it out and managed to make it work. Thank you so much!!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.