Player Argument must be a Player Object

Does anyone know how to get around the error
FireClient: player argument must be a player object.
Ive trying to make sense of the roblox Developer Website https://developer.roblox.com/en-us/api-reference/function/RemoteEvent/FireClient but there is no thing on there about the error “FireClient: player argument must be a player object”. In fact, really ive been searching google and either someone got around the problem BUT didn’t post the solution, or nobody knows about it. Here is the script, I am using a RemoteEvent.

— listener
local Dummy1 = game.Workspace.Dummy1
local player = game:GetService(“Players”)
local VPlayer = player.LocalPlayer

game.Workspace.Dummy1.Humanoid.HealthChanged:Connect(function()

print "Health Changed, sending signal."

game.ReplicatedStorage.Events.WantedLevel1Event:FireClient(VPlayer)

end)

and on a unrelated note, is there anything related to LocalPlayer but instead of a local script
its a server script?

3 Likes

Please do not post images of code/exceptions. Instead, post them as text.

4 Likes

Hang on, let me quickly fix that.

3 Likes

You’re passing Players.LocalPlayer to the first argument of FireClient.

  • If this is a LocalScript:
    You’re looking for :FireServer, and you can remove the player argument.
  • If this is a Script/ServerScript:
    You cant access Players.LocalPlayer from the server, it only works on the client, you’d need the Player instance to be passed to FireClient.
6 Likes

could have edited my post but eh wanted to make a separate reply based solely on helping you

The server has no concept of a local player, the common way of getting the player is through events.

1 Like

But how would I do that? I am also a tad bit confused on the best way to do so.

1 Like

Seeing the console error, this is a server error. You cannot access LocalPlayer on the server, hence this is set to nil when attempting to fire the remote for the player.

You would have to do

Remote:FireClient(player["PlayerName"]) --gets the player object based on the defined player name

However, since there is limited information provided, I cannot provide any further suggestions. Can you please provide more context about what you’re trying to accomplish here?

12 Likes

If you’re looking to do this on all players use :FireAllClients where the worry of needing to specify a player can be completely dropped.

7 Likes