Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I need help I am trying to display the the person leader board stats as a GUI can you help me?

Asked by 6 years ago

I have been trying to do this for a couple of hours but it wont work, Here is my leader board script so far.

01game.Players.PlayerAdded:connect(function(plr)
02    local stats = Instance.new('IntValue', plr)
03    stats.Name = 'leaderstats'
04    local cash = Instance.new('IntValue', stats)
05    cash.Name = 'Cash'
06    cash.Value = 0
07    local c = game.StarterGui.Leaderboard.Frame.TextLabel
08    wait()
09    c.Text = "Cash: "..cash.Value
10 
11end)

I need it so it is the players stats that he/she is looking at I want it as a text label after Cash:

1 answer

Log in to vote
1
Answered by 6 years ago

Delete line 7,8 and 9 and make a local script in game.StarterGui.Leaderboard.Frame.TextLabel with this code:

1local gui = script.Parent
2local cash = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Cash")
3 
4while wait() do
5    gui.Text = "Cash: "..cash.Value
6end
Ad

Answer this question