Why does this not work?
local user = game.Players.LocalPlayer local stats = user:findFirstChild("leaderstats") while true do script.Parent.Text = "" .. user.leaderstats.Coins.Value .."" wait(0.1) end
Error:
Script 'Players.Player.PlayerGui.Leaderboard Tires.Leaderboard.Coin.Display', Line 4
and
leaderstats is not a valid member of Player
Use WaitForChild
. It will delay until it finds the required object. Also, you do not need those set of quotes around the string.
Also, use events rather than a loop. It's much more efficient.
local user = game.Players.LocalPlayer local stats = user:WaitForChild("leaderstats") local coins = stats:WaitForChild("Coins") function update() script.Parent.Text = coins.Value end coins.Changed:connect(update)