Remote events returning nil?

Why does the second value in this remote print as nil?

local remoteEvent = game.ReplicatedStorage.Remotes:WaitForChild("PlayCard")

script.Parent.MouseButton1Click:Connect(function(Player)
	remoteEvent:FireServer(Player, "Five")
end)

image

local function playCard(Player, Card)
	print(Player, Card)
end

PlayCard.OnServerEvent:Connect(playCard)

You don’t have to fire the player argument in the function as the .OnServerEvent event already has the player instance in the argument. Also, MouseButton1Click events does not have any arguments embedded in the function, so that’s why it is nil. You should only just fire the remote event with the "Fire" as the argument and then when the server receives it it receive the player argument and the data you sent to the server.

2 Likes

From my understanding your returning a player from a serverevent. You don’t have to do that.
Try this in the client script:

local player = game.Players.LocalPlayer
local event = game.ReplicatedStorage.Remotes:WaitForChild("PlayCard")

script.Parent.MouseButton1Click:Connect(function()
	remoteEvent:FireServer(player, "Five")
end)

You cant call the player function in a local script when you can just use the localPlayer.

Yeah so I figured out I don’t need player at all and infect the server just knows automatically, so if in the server function I type “player” it just knows. Thanks for the help though!

1 Like