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

How to take damage once a animation is playing?

Hey guys I need help with the current weapon I'm doing.. It's basicly a baseball bat that when you click it it plays an animation and then damages the player it touched.. But everytime it touches a player it deals ALOT of damage .. like 80+ every time. Here's the code:

--//The animation is fine so I wont include it in the code

script.Parent.MouseButton1Click:connect(function()
--//Play the animation script..
script.Parent.Handle.Touched:connect(function(smash)
smash.Parent.Humanoid:TakeDamage(15)
print("You just got hit! Too bad.")
wait(1)

end)

The prob is that I want the humanoid to only take damage ONE time ONCE it has been hitted.. I tried for i = v do, take damage... But none worked... Can someone help with this?

I aprecciate ANY help,tip or comment. Thanks alot!

1 answer

✓ Accepted answer

I haven't tested this but hopefully this helps.

local de = false
script.Parent.MouseButton1Click:connect(function()
--//Play the animation script..
script.Parent.Handle.Touched:connect(function(smash)
if not de then
de = true
smash.Parent.Humanoid:TakeDamage(15)
print("You just got hit! Too bad.")
wait(1)
de = false
end
end)

Just reply If It doesn't work.

1 comment

0

Worked 100%. Thanks alot! Why didn't I think that before?

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