Remote event from client to server doesn't pass variables

Script:

event.OnServerEvent:Connect(function(player, ID)
	print(player, ID)
end)

LocalScript:

local Players = game:GetService("Players")
local localplayer = Players.LocalPlayer
local ID = 2

event:FireServer(localplayer, ID)

Output:
Vnyxx, Vnyxx

you don’t send the player

Do this:

InventoryEquip:FireServer(Id)
1 Like

If it is in a local script, it cannot run events on the server.

How would I know the player in the script without passing it?

The player that fired a RemoteEvent is passed as the first argument if you pass the player to the server like you did you’d have to do:

RemoteEvent.OnServerEvent(player,player,Id)
1 Like

Would be:

:Connect(function(player, localPlayer, ID)

end)

Remove the localplayer in your FireServer. OnServerEvent carries the player as the first argument (the player that fired the event).

1 Like

just do this

--server 

Remote.OnServerEvent:Connect(function(player,Id)

end)
--client

Remote:FireServer(ID)
2 Likes