"Attempt to index nil with 'WaitForChild'

So I am trying to make a script where whenever the player reaches the currency backpack limit than a gui will pop up. I don’t really know the reason why im getting this error

script:

local Players = game:GetService(“Players”)

local Player = Players.LocalPlayer

local PlayerGui = Player:WaitForChild(“PlayerGui”)

local Frame = PlayerGui:WaitForChild(“CurrencyMax”).Background

local leaderstats = Player:FindFirstChild(“leaderstats”)

while wait() do

if Player.leaderstats.Clicks.Value == Player[‘Click Backpack’].Value then

PlayerGui.Frame.Visible = true

end

end

1 Like

The Already Asked Question Check Is this on a Server or a Local Script?

1 Like

This script is on a normal script

1 Like

INHALE

You cannot get the Local Player on a Normal/Server Script, using Server Scripts anywhere will not be able to find the Local Player anywhere

Change it to a LocalScript and see if that fixes your issue

3 Likes

yeap fixed thx so much for rem me

1 Like

Np, also do make sure to mark it as a solution so that members are aware of it being solved :wink: