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

What method is best to make a player punch?

Do I need to make a animation or do I need to make a long script using CFrame to move the arm?

My Idea was to play a animation and while that animation is playing to make it so if you touch the arm you get damaged. But am I able to do this and is there a better way?

1 answer

✓ Accepted answer

Use animations

You can move the arm using animations. Because the player's character is replicated to the server, you can play the animation in a Local Script if you wish. However, if FE is enabled, you will have to do the damage in a regular script so it affects other players.

To make sure the arm doesn't hurt the Local Character, use the IsDescendantOf() function. Example,

local char = "DefineCharacter"

arm.Touched:connect(function(p)
	local hum = p.Parent:FindFirstChild("Humanoid")
	if (not p:IsDescendantOf(char)) and (hum) then
		hum.Health = hum.Health-5
	end
end)
Just an example

Good Luck!

If I helped, please don't forget to accept my answer.

2 comments

0

What's the point of the parentheses surrounding the if and not statements? Some people do it but others don't. Is there a reason for it

0

Not really. It's mainly used for organization.

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