FireClient: player argument must be a Player object error

I was trying to fire an event but it gave me this error even though got the player from character. I cannot think of any solutions so can someone explain why it gave me this error and the solution?

	local plr = game.Players:GetPlayerFromCharacter(char)

There’s more code but it is definitely irrelevant.

Edit 1: Grammar fixed

1 Like

You should print first in order to explain it to yourself. I believe in you, that you can solve it on your own if you do.

However from the code I’m guessing char is equal to nil and so player is nil because task.spawn doesn’t pass any parameters into the anonymous function given.

local char = --Get char outside of task.spawn
	local plr = game.Players:GetPlayerFromCharacter(char)
print(typeof(plr), plr, char)
1 Like

Uhm… I have a problem
This is a ServerScript so it is impossible to make a variable for the char…
(Or I’m too dumb too actually find a solution!)

The variable char is nil. So the plr variable is also nil.

task.spawn() doesn’t return anything its just blank like that. You gotta use alternativs ways getting player character.

I’m an idiot, can you tell me some alternatives?

Can you provide more of your code? Where are you trying to get the character?

Alternatively, are you trying to fire this event for everyone? If so, you can use :FireAllClients instead.

Assuming you did want to fire it to everyone’s client, here is an implementation on how:


This code is in a server script, and I am trying to get the character who triggered the event.
Also, I didn’t want to fire for all clients

How are you detecting when the event is triggered? Could you showcase more of the code or the event?

	print("Still Waiting!")
until (Darkness.Position-Trigger.Position).Magnitude < 4


Edit 1: I don’t think that you can fire a function with magnitude

Could you tell me what kind of event that you used? like Proximityprompt.Triggered?, part.Touched?

none 30char 30char 30char 30char

Hmm Alright could you provide your whole codes of script? we might need to take in depth on your script so we can know how can we get player instance.

Sorry for the late response :expressionless:
Also I changed the script a bit

local Darkness = workspace.Darkness
local Trigger = script.Parent
local Hinge = workspace.End.ExitDoor.Hinge
local GameWin = game.ReplicatedStorage.GameWin
local TS = game:GetService("TweenService")

local WinFrame = game.StarterGui.ScreenGui.WinFrame

local Alarm = workspace.Alarm
local SmilerScreeh = workspace.Darkness.SmilerScreech
local DoorBang = workspace.GameStartPart.DoorBreak
local SmilerLight = workspace.Darkness.SmilerLight

local tweeninfo2 =
local ClosingTween = TS:Create(Hinge, tweeninfo2, {CFrame = Hinge.CFrame * CFrame.Angles(0, math.rad(0), 0)})

local function CheckMagnitude(plr)
	SmilerLight.Brightness = 0
	WinFrame.Visible = true

	print("Still Waiting!")
until (Darkness.Position-Trigger.Position).Magnitude < 4


Alright so you want like when the function called, you want every player gui turned on? because I’ve seen a starter gui

and i see that you wanna fire client after called that function?

Ye. I tried to just make it visible but of course that failed

do like this (im on mobile btw)

put this codes inside the function

for _, player in pairs(game.Players:GetPlayers()) do
  local WinFrame = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("WinFrame") 
    WinFrame.Visible = true

1 Like

Wait how about the remote event fire client?

I think i’m just going to make this a 1 player server