OnClientEvent value Gets Nil instead of player name

  1. What do you want to achieve?
    I just want the player name

  2. What is the issue?
    The receiving (local script) end gets nil but the sender (server script) end prints the name.

  3. What solutions have you tried so far?
    Ive looked around on devforum but nothing helped and ive tried different varieties of sending the player name, nothing has worked.

--Server script
	if player then
		local donoRE = ReplicatedStorage:WaitForChild("SystemMessengerEvents").MessageREs.DonationMessageREs:FindFirstChild("Donated" .. donatedAmount)
		print(donoRE)
		print(game:GetService('Players'):FindFirstChild(player.name))
		donoRE:FireClient(game:GetService('Players'):FindFirstChild(player.name))
		print("DONE")
	end
--Local script
dono1K.OnClientEvent:Connect(function(plrName)
	task.wait(5)
	print(plrName)
end)

The prints in the server side works as intented but the print in the local script after everthing ive tried is nil.

Local script is in starterPlayerScripts and server script is in workspace.

1 Like

Its probably cause :FindFirstChild(player.name) didin’t work or something.

If you already got the player up at the start

why don’t you just do this:

donoRE:FireClient(player.Name)

Could be also cause you misspelled name should be Name

1 Like

You never send the player name to the client.
You want to do
RemoteEvent:FireClient(player, playerName) with player being the client you are sending the info to.

3 Likes

When i did that the remote event did even fire, so i tried other ways such as the one on my post and it did fire, i have no idea why though.

1 Like

This would be more correct @Hawkingsralf

2 Likes

With RemoteEvent:FireClient() the first argument always has to be the client/player you are sending the information to.
RemoteEvent:FireClient(player) sends the information to one certain player
RemoteEvent:FireAllClients() doesn’t take a player argument as it sends information to all clients

2 Likes

Thanks for the quick solution :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.