FireClient: player argument must be a Player object help?

Here’s my script:

game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireClient(ehuman)

ehuman is a humanoid
my output is: FireClient: player argument must be a Player object and I don’t understand.

3 Likes

You have to use the first argument as the Player instance, not their humanoid.

1 Like

You can use the following to get the player from that humanoid

local plr = game.Players:GetPlayerFromCharacter(ehumanoid.Parent)

So it would be

local plr = game.Players:GetPlayerFromCharacter(ehumanoid.Parent)
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireClient(plr)

(Meant to reply to the original post.)

2 Likes

Yes, that would work, but I am giving the reason why it isn’t working in general.

2 Likes

A player object is the object inside the Players folder. The Humanoid is an object inside the player’s character object. Since you are trying to fire it to a Humanoid (which is inside a player’s character) this is why you are getting this error. Instead, you must fire it to the player object.

The most easy way to do this is shown below:

local player = game.Players:GetPlayerFromCharacter(ehuman.Parent) -- Getting the player from the character (which the Humanoid is inside)
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireClient(player)
5 Likes

it does the same thing what should I do

Are you sure you are referencing the ehuman variable in the correct way? If you have it referring to the player’s humanoid the script above should work.

1 Like

nevermind i forgot to add .Parent! Thanks.

1 Like

Glad you got it working. No problem. :slight_smile:

1 Like

If it works for you, don’t forget to mark it as the solution so others can easily find it!