Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Showing leaderboard stats?

Hi I was wondering if you could display the stats on the leaderboard in a textlabel. For example you have 4000 points in your balance. Can you please help me with this?

1 comment

0

Of course You can. Its a pretty easy method.

2 answers

✓ Accepted answer

When you have leaderstats, the layout should look like this:

Players
	Player
		leaderstats
			Points

A TextLabel in a ScreenGui can easily access these stats using a LocalScript.

game.Players.LocalPlayer.leaderstats.Points.Changed:connect(function()  --This checks if the "Points" stat changed.
	script.Parent.Text = game.Players.LocalPlayer.leaderstats.Points.Value
end)

6 comments

0

That didn't work in a local script...

0

I might have the script wrong. Is the LocalScript in the TextLabel and did you change "Points" to the stat's name?

0

yes

0

That's odd, it works perfectly fine when I test it. What does output say?

0

Don't use while true do like that, it's horribly inefficient. Use events, like Changed.

0

My bad, thanks for pointing that out! I edited my answer.

If you are trying to show your stats, you would do this.

P = game.Players.LocalPlayer
script.Parent.Text = "Points: "..P.leaderstats.Points.Value
end

Just insert this script directly into your local script located in the text label. And if you arent using leaderstats for a stat holder, change the name to whatever holder you are using.

2 comments

0

Why is there an end?

0

If scripts like this dont have an end it shows the red line under it.

This discussion is preserved as it was. New answers, comments, and votes are closed.