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

Damage Script doesn't do no damage?

So, I'm making a combat script, that is basically finished, but I cannot figure out why it doesn't work.

dmg = true

dmg = true

script.Parent.Touched:connect(function(hit)
if hit.Parent.Parent.Parent.Parent.Humanoid and dmg == true then
hit.Parent.Parent.Parent.Parent.Humanoid:TakeDamage(5)
dmg = false
wait(1)
dmg = true
script:Destroy()
end
end)

So, basically the combat script clones a script into a Player's arm, but it doesn't seem to do any damage to anyone. Know why? [Btw this is a script.]

1 answer

✓ Accepted answer

Hello, look, I miss it in a LocalScript inside the leg and you can put it as a punch as well or any other movement.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService") 
local Animation = Instance.new("Animation", Humanoid)
Animation.Name = "kick"
local AnimationTrack = Humanoid.Animator
Animation.AnimationId = "rbxassetid://" 
local LoadedAnimation = AnimationTrack:LoadAnimation(Animation)
local Sound
local CanDamage = false

LoadedAnimation.Stopped:connect(function()

    CanDamage = false 
end)


UserInputService.InputBegan:connect(function(Input, GME)

    if not GME then 

       if Input.KeyCode == Enum.KeyCode.Q then 
			
			LoadedAnimation:Play()
			CanDamage = true
			local slash = Instance.new("Sound", Humanoid)
			slash.SoundId = "rbxassetid://158037267"
			slash.Volume = 0.8
			slash.Pitch = 1.4
			slash:Play()
			wait(0.2)
			slash:Destroy()
            wait(0.3)
			LoadedAnimation:Stop()
			
        end

    end

end)

 

local Cooldown = false

script.Parent.Touched:connect(function(Part)

    local Human = Part.Parent:findFirstChildOfClass("Humanoid")

    if Human and Human.Parent.Name ~= Character.Name and CanDamage and not Cooldown then
	
        Cooldown = true

        Human:TakeDamage(20)
		Sound = Instance.new("Sound",Humanoid)
		Sound.SoundId = 'rbxassetid://743886825'
        Sound:Play()
		wait(0.2)
		Sound:Destroy()
        wait(1.5)

        Cooldown = false

    end

end)

1 comment

0

that is not very helpfull

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