Need help with a simple damage script that won't work no matter what i do

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I wanna make a kill sequence that’s synchronized with my animation

  2. What is the issue? Include screenshots / videos if possible!
    Literally nothing happens, not even damage or sounds

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried looking at the developer forum, importing a kill sequence from an old game, changing the humanoid names (they used to be called knights but now they’re just enemy)

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
The knight attacks work perfectly fine tho, as seen in the video

-- local debounce = false
local animation = script:WaitForChild('Animation1')
local Humanoid = script.Parent.Parent:WaitForChild('Humanoid')
local dance = Humanoid:LoadAnimation(animation)
local bites = {script.Parent.Parent.Head.Bite1,script.Parent.Parent.Head.Bite2,script.Parent.Parent.Head.Bite3}
local gore = {script.Parent.Parent.Head.Gore1,script.Parent.Parent.Head.Gore2,script.Parent.Parent.Head.Gore3,script.Parent.Parent.Head.Gore4,script.Parent.Parent.Head.Gore5}

function onTouched(hit)
        local human = hit.Parent:findFirstChild("Enemy")
		if (human ~= nil) then
		if not debounce then
			debounce = true
			dance:Play()
			Humanoid.WalkSpeed = 0
			wait(1)
			human.Health = human.Health - 20 -- Change the amount to change the damage.
			bites[math.random(#bites)]:Play()
			local weld = Instance.new("Weld") 
			weld.Part0 = script.Parent.Parent.Head
			weld.Part1 = hit
			local HitPos = script.Parent.Parent.Head.Position
			local CJ = CFrame.new(HitPos) 
			local C0 = script.Parent.CFrame:inverse() *CJ 
			local C1 = hit.CFrame:inverse() * CJ 
			weld.C0 = C0 
			weld.C1 = C1 
			weld.Parent = script.Parent
			wait(0.55)
			human.Health = human.Health - 80 -- Change the amount to change the damage.
			bites[math.random(#bites)]:Play()
			gore[math.random(#gore)]:Play()
			wait(0.45)
			Humanoid.WalkSpeed = 15
			weld:Remove()
			wait(3)
			debounce = false
        end
	end
	end
script.Parent.Touched:connect(onTouched)

Please help i even tried making it a small little damage script and not even that works

function onTouched(hit)
        local human = hit.Parent:findFirstChild("Enemy")
	if (human ~= nil) then
		human.Health = human.Health - 20 -- Change the amount to change the damage.
	end
end
script.Parent.Touched:connect(onTouched)

Not even this works and the output says no errors i need help.
Video:


(the hitbox is supposed to trigger the kill sequence btw)

1 Like

Capitalize Find . . . . . . . .

And also Connect here:

1 Like

Still doesn’t work. Is there seriously no other errors?

1 Like

UPDATE: i moved the startercharacter to the workspace and clicked run, then dragged all the knights to the hitbox and it seems to work. Maybe i should make it a local script. Edit: still didn’t work

1 Like

Capitalize the :connect like this :Connect

1 Like

Already did that, still not working

1 Like

What is “Enemy?” Your script hit.Parent call will be the enemy player, and the enemy player’s health is under their humanoid, so unless another script is renaming all player humanoids to “Enemy” you should do hit.Parent:FindFirstChild("Humanoid") instead.

1 Like

No because enemy humanoids are called enemy and i don’t want infighting

OK guys i will try to turn it into a tool instead and see how it goes

If you want to limit any potential self-damage or damage of the wrong players then you should have a system for handling player roles rather than naming the humanoid. You might make a sword in the future and assume “Enemy” is the target out of habit then it turns out the players can only kill each other.

Anyway, good luck!

I split the animation into 6 animations and the hitbox into 2 tools, 3 animations each. Now it really works well and probably better than how the hitbox would’ve worked.