Client to server damage

I’m trying to do the visual effects on the client then when a part is touched it sends an event to the server to do damage.

--Client Side 
Arc.Touched:Connect(function(hit)
		local plr_hit = hit.Parent
		local Hum = plr_hit.Humanoid
		if Hum then
			game.ReplicatedStorage.ArcDMG:FireServer(hit)
			print(hit.Parent)

		end
-- Server Side
local function DoDmg(hit)
	print(hit)	
end

game.ReplicatedStorage.ArcDMG.OnServerEvent:Connect(DoDmg)

Client-side prints whats being hit (in this case the Dummy)
Whilst the server-side constantly prints my name.

Sorry if this has a easy solution I just can’t seem to get around it.
Thanks!

1 Like

The first parameter passed to an OnServerEvent will always be the player who fired the remote event.

Try this.

local function DoDmg(player, hit)
	print(hit)	
end

Also, the way you are doing this looks insecure. If you freely allow any player to pass whoever got damaged by a part then you may run into the issue of an exploiter joining your game and killing everyone.

2 Likes

Thanks didn’t know that. :slight_smile:

And I was just using this as a placeholder for now before getting into the security much.