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.
local Dummy1 = game.Workspace.Dummy1
local player = game:GetService(“Players”)
local VPlayer = player.LocalPlayer
print "Health Changed, sending signal."
and on a unrelated note, is there anything related to LocalPlayer but instead of a local script
its a server script?
Hang on, let me quickly fix that.
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.
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.
But how would I do that? I am also a tad bit confused on the best way to do so.
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?
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.