How to make the attack strength equal to the time of punching?
my punch cooldown is working but my damage script is also spam damage while punch cooldown still stop playing
here my punch cooldown code
01 | local player = game.Players.LocalPlayer |
06 | local anim = Instance.new( "Animation" ) |
09 | game.Players.LocalPlayer.Character:WaitForChild( "RightHand" ).Touched:Connect( function (hit) |
10 | if hit.Parent:FindFirstChild( "Humanoid" ) and db 2 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) |
17 | game:GetService( "UserInputService" ).InputBegan:Connect( function (input, event) |
18 | if input.UserInputType = = Enum.UserInputType.MouseButton 1 and db then |
23 | local playAnim = game.Players.LocalPlayer.Character:WaitForChild( "Humanoid" ):loadAnimation(anim) |
and code of damage script
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | player.CharacterAdded:Connect( function (char) |
03 | local sound = game.ServerStorage.Punch:Clone() |
04 | sound.Parent = char:WaitForChild( "Head" ) |
09 | game.ReplicatedStorage.Punch.OnServerEvent:Connect( function (player, humanoid) |
10 | if humanoid.Health > = 10 then |
11 | humanoid.Health = humanoid.Health - 10 |
12 | elseif humanoid.Health < 10 then |
16 | player.Character.Head.Punch:Play() |
Please Help And Thanks You.