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

Best hitbox and damage method for a punch script?

Whats the best method to make a networked combat/punch script do damage? Is it magnitude, raycast, or just using a simple touch event?

A little example would also be helpful, after that i can take it from there. Please and thank you.

1 answer

✓ Accepted answer

Touched event and getting a character from the hit would be best

local hitter=--maybe your arm/hand or a tool
local hitting=false

--change hitting when your doing an action

hitter.Touched:Connect(function(hit)
	if hitting then
		if hit.Parent:FindFirstChild("Humanoid")~=nil then
			hit.Parent.Humanoid:TakeDamage(10)
		end
	end
end)

7 comments

0

Isn't this really bad? I mean as a exploiter. You could just teleport a part of the enemy or whatever and hit it from a position it is not.

0

@aiza_teizuki no, you lose out on performance by doing it more complexly to combat exploiting, but no one is stopping you from creating OTHER scripts or MODIFY this one just a bit to combat things like this

0

e.g distance from characters

0

Yeah I get that, But I just meant in general. Not having that distance check could allow some people to easily break a entire lobby. ( If we are talking about a rpg styled game ).

0

@aiza_teizuki NOT if this is a server script, which in most cases will be

0

and if the player is tping themselves then it might be best to implement something to stop that directly

0

yeh you need remote events

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