How to pass an argument from a local script to a server script with the help of events?

So I have a local script in which I get the part my tool touched. I need to get the same part that I touched in the server script, how do I do it?
Local script:

event:FireServer(hit)

Script:

local event = script.Parent:WaitForChild("WallEffects")

event.OnServerEvent:Connect(function(hit)
	print(hit)
end)

But when I try to do this, the function creates it as a player instead of my part

3 Likes

Because the first argument is always the Player, so put the arguments like this:

(player, hit)

3 Likes

Yup anything done by client → server will have the first argument as the player.
I suggest checking the documentation first before posting since it might save you a ton of time.

Just google “roblox (whatever you need scripting wise)”
For example “roblox remote event”

1 Like

The client will automatically send the player as a first argument when you fire an event from it so you dont need to supply it. But when the event arrives on the server the first argument must always be the player, i.e.:

event.OnServerEvent:Connect(function(player,hit)
	print(player.Name .. " hit " .. hit)
end)