Hello, so recently i made my Punching script(local script), that works perfectly fine on local server. Basically it creates invisible part(hitbox), and when it gets touched by a humanoid, while user is doing a punch, it takes health from that humanoid. But, even though animation of punches is getting played, damage only shows on local server.
--damage function in local script
part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
if candmg == true then
print("got hit")
hit.Parent.Humanoid:TakeDamage(5)
candmg = false
end
end
end)
--part is a hitbox
how do i properly bind this function to a remote event?

4 comments
https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
Hello, main issue is that hitbox is being created in local script, therefore how do i make if that part is touched function in Remote Event connection script?
Don't make parts in local scripts. Make the part in a server script then you can just run a Touched event in an other server script for the hitbox to detect if a player has punched it
In other words. Made hitbox, then inside hitbox goes a script (Copied from somewhere like ServerStorage) in said hitbox with a touched event. the hit part just check to see if it is an arm belonging to a player and then if it is candmg == true then do the damage