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

Tool only does damage once then never does damage again on enemies how to fix?

So I created a custom tool for my game with animation. It works just fine, I can swing it and it shows up in my hand. I added a damage script and it works, just only 1 time. After I swing and successfully damage something it never damages anything again no matter how many times I swing. I can reset this by going out of test and going back in but that doesnt help only just resets my game in studio. Here is the script.

script.Parent.blade.Touched:connect(function(p)
	if script.Parent.CanDamage.Value == true then
		script.Parent.CanDamage.Value = false
		p.Parent.Humanoid:TakeDamage(5)
	end
end)

The BoolTool is named "CanDamage" and is activated.

1 answer

✓ Accepted answer

You forgot to set the value of CanDamage back to true.

script.Parent.blade.Touched:connect(function(p)
    if script.Parent.CanDamage.Value == true then
        script.Parent.CanDamage.Value = false
        p.Parent.Humanoid:TakeDamage(5)
    else
        script.Parent.CanDamage.Value = true
        p.Parent.Humanoid:TakeDamage(5)
    end
end)

Hope it works!

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