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

How to make the punch cooldown?

Asked by 5 years ago

How do I need to make it cooldown punch because there too op for every second i want to make it cooldown like like 1 second Here the code

01local player = game.Players.LocalPlayer
02local db = true
03local damage = false
04 
05local anim = Instance.new("Animation")
07 
08game.Players.LocalPlayer.Character:WaitForChild("RightHand").Touched:Connect(function(hit)
09    if hit.Parent:FindFirstChild("Humanoid") and not db and not damage and hit.Parent.Humanoid ~= game.Players.LocalPlayer.Character.Humanoid then
10        if game.Players.LocalPlayer.Character.Humanoid.Health > 0 then
11            damage = true
12            game.ReplicatedStorage.Punch:FireServer(hit.Parent.Humanoid)
13        end
14    end
15end)
View all 28 lines...

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This should work.

01local player = game.Players.LocalPlayer
02local db = true
03local db2 = false
04local damage = false
05 
06local anim = Instance.new("Animation")
08 
09game.Players.LocalPlayer.Character:WaitForChild("RightHand").Touched:Connect(function(hit)
10    if hit.Parent:FindFirstChild("Humanoid") and db2 and not damage and hit.Parent.Humanoid ~= game.Players.LocalPlayer.Character.Humanoid then
11        if game.Players.LocalPlayer.Character.Humanoid.Health > 0 then
12            game.ReplicatedStorage.Punch:FireServer(hit.Parent.Humanoid)
13        end
14    end
15end)
View all 31 lines...
1
Thanks you OrewaKamidaa 40 — 5y
0
No problem, @OrewaKamidaa. Vinceberget 1420 — 5y
1
wait dude @Vinceberget its work but i can spam it when it was after cooldown OrewaKamidaa 40 — 5y
0
It should work better now Vinceberget 1420 — 5y
1
@Vinceberget OMG DUDE U ARE RLLY COOL OrewaKamidaa 40 — 5y
Ad

Answer this question