Attempt to index nil with WaitForChild, i cant find a solution

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a Text Label appear after a remote event is fired, to be clear, the server script is firing the event to the client. And this screenshot is from the serverscript
    The script goes as follows;
-- Server Script
local textLabel = game.Players.LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("InGame").WaitingText
game.ReplicatedStorage.Events.waitingText:FireClient(game.Players.LocalPlayer, textLabel)
-- Local Script
game.ReplicatedStorage.Events.waitingText.OnClientEvent:Connect(function(textLabel)
	textLabel.Visible = true
end)

and the output spit out;
3ewqq
(line 24 is where the “textLabel” variable is located)

I have tried changing :WaitForChild(“PlayerGui”) to :FindFirstChild(“PlayerGui”) and just .PlayerGui but they all spit out

"attempt to index nil with ..."
-- For Example
"Attempt to index nil with 'WaitForChild'"
"Attempt to index nil with 'FindFirstChild'"
"Attempt to index nil with 'PlayerGui'"
3 Likes

If this is a server script, which I believe it is if I understood correctly, you can’t use LocalPlayer.

1 Like

You cannot use Players.LocalPlayer in a server script

Replace LocalPlayer with a PlayerAdded function to get players who are joining.

then what could I use as LocalPlayer for a serverscript?

You could use PlayerAdded, or some other function that has a player parameter. Whatever kind of function fits your purpose.

1 Like

Yep, call on the Player in your function: game.Players.PlayerAdded:Connect(function(Player)

How will the event be fired?

30chars