Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Combat Script Damage is not working properly ?? One Hit everything

local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
Combo = 1
CanDamage = false
local enabled = true



repeat wait() until game.Workspace:FindFirstChild(player.Name):FindFirstChild('Humanoid')  -- Load Humanoid in Workspace


local Anim = game.Workspace:FindFirstChild(player.Name):FindFirstChild('Humanoid') :LoadAnimation(script.Punch1)  -- Load Animation in Humanoid



local Anim2 =  game.Workspace:FindFirstChild(player.Name):FindFirstChild('Humanoid') :LoadAnimation(script.Punch2)  -- Load Animation in Humanoid



UIS.InputBegan:connect(function(key, gameproc)
if not gameproc and key.KeyCode == Enum.KeyCode.Q and Combo == 1 then
if not enabled then return end
enabled = false
CanDamage = true
Anim:Play()
wait(0.7) -- Cooldown to the Animation
Combo = 2 -- Switch to Combo 2
enabled = true
game.Workspace:FindFirstChild(player.Name):FindFirstChild('RightHand').Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and CanDamage == true then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(2)
wait(1.2)
end
CanDamage = false
end)
elseif not gameproc and key.KeyCode == Enum.KeyCode.Q and Combo == 2 then
if not enabled then return end
enabled = false
CanDamage = true
Anim2:Play()
wait(0.7) -- Cooldown to the Animation
Combo = 1 -- Back to the Start
enabled = true
game.Workspace:FindFirstChild(player.Name):FindFirstChild('LeftHand').Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and CanDamage == true then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(6)
wait(1.2)
end
CanDamage = false
end)
end
end)

The Damage one hit everything I tried messing with the CanDamage but it doesn't do a thing only making it slower but still after two punches the humanoid is dead and the damage is low like I didn't set it on 4000 or something higher .

Help me please

3 comments

0

Check the MaxHealth of Damage Receiver, You might mistaken that it has 100 MaxHealth.

0

Tab your code correctly!

0

... It looks fine to me

1 answer

For every moment the combat script is on and the tool or hand or whatever is touching the humanoid, they will take damage. This leads to taking more than the damage they were supposed to be given.

This discussion is preserved as it was. New answers, comments, and votes are closed.