I have recently been making a game, where i need a specific NumberValue to show up on a GUI element. However my script doesn´t seem to work, and the following message is printed in the output: Infinite yield possible on 'Players.AndriusTheGreat:WaitForChild("leaderstats")'.
The script is a localscript that lies inside a folder in StarterGui
Here is the script:
game.Players.PlayerAdded:Connect(function(player)
local StartingMoney = 100
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("NumberValue")
money.Name = "money"
money.Parent = leaderstats
money.Value = StartingMoney
end)
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
leaderstats.money.Value = 10
game.StarterGui.Guis.ScreenGui.FrameT.TextLabel.Text = leaderstats.money.Value

1 comment
That means it might be waiting forever for a child called "leaderstats". Double check it's actually supposed to exist and debug why it doesn't. Check spelling etc.