Is it a bad idea to handle hitboxes with GetTouchingParts?

I have a server script that handles my hitboxes for weapons.

Essentially, this is what my code does:

RunService.Stepped:Connect(function()
	if DoDamage then
		local Parts = Hitbox:GetTouchingParts()
		for i,v in pairs(Parts) do
			Damage(v)
		end
	end
end)

What I want to know is if this will effect the server in anyway (e.g. lag server)?

2 Likes

You cannot use RunService inside a server script.

Yes you can. The code works.

No. GetTouchingParts extremely inexpensive, however in terms of Melee (I don’t know your use case) it would work far better to use this:

But for projectiles this should be fine.