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

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

Asked by 7 years ago

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)

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. XAXA 1569 — 7y
0
thanks creeperhunter76 554 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
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.

0
thanks but it doesn't work initially. I need to change the level manually then it will start working. any fix? creeperhunter76 554 — 7y
0
on line 4 you can just paste: LevelText.Text = player.leaderstats.Level.Value tigergo4 83 — 7y
Ad
Log in to vote
0
Answered by
0msh 333 Moderation Voter
7 years ago

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!

Answer this question