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

how do i add a cooldown to this old wepon script?

Asked by 3 years ago

i want to add a cooldown to this old wepon script i made, can someone help me do that?

01local tool = script.Parent
02 
03local canDamage = false
04 
05 
06 
07local function onTouch(otherPart)
08 
09 
10 
11    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
12 
13 
14 
15    if not humanoid then
View all 59 lines...

1 answer

Log in to vote
1
Answered by
0hsa 193
3 years ago
Edited 3 years ago

didn't understand what you mean by cooldown, damage? clicking?

01local tool = script.Parent
02 
03local canDamage = false
04 
05local Cooldown = false
06 
07local WaitTime: number = 0.3 --// anything
08 
09local function onTouch(otherPart)
10    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
11 
12    if not humanoid then return end
13 
14    if humanoid.Parent ~= tool.Parent and canDamage then
15        humanoid:TakeDamage(5)
View all 41 lines...
Ad

Answer this question