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

How can I make it so a TextBox displays a value from a leaderboard value?

heres my script

local data = game.Players.LocalPlayer:WaitForChild('Data')
local lvl = data:WaitForChild('Level')
local lvlvalue = lvl.Value
game.Players.PlayerAdded:connect(function(player)
	script.Parent.Text = lvlvalue
end)

2 comments

0

I'm guessing that the connection to the PlayerAdded event is completely unnecessary. Also, you might want to update it automatically whenever lvl changes, with the .Changed event.

0

thanks

2 answers

✓ Accepted answer
local player = game.Players.LocalPlayer
player.PlayerGui:WaitForChild("ScreenGui")
local LevelText = player.PlayerGui.ScreenGui.TextLabel

player.leaderstats.Level.Changed:connect(function()
	LevelText.Text = player.leaderstats.Level.Value
end)

Basically I used the .Changed event to set the text of the textlabel every time your level is changed.

2 comments

0

thanks but it doesn't work initially. I need to change the level manually then it will start working. any fix?

0

on line 4 you can just paste: LevelText.Text = player.leaderstats.Level.Value

This is a local script inside of the Text Label (I recommend Text Label not Text Box if you want it to show player's stat). It is very simple.

repeat
	wait(.5) -- Refresh
script.Parent.Text = ""..game.Players.LocalPlayer.leaderstats.Level.Value..""

until false

Please accept answer if works!

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