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

How do I set the text of a textlabel to a value within a player's leaderstats?

Asked by 4 years ago
Edited 4 years ago

Hello,

So I am making a game called Mining Incorporated and i'm currently working on the gui's. I have disabled the leaderboards but the leaderstats folder is still withing the player. Now I have a textlabel to display the amount of coins you have and coins get added for every ore you sell. I can not figure out how to do it, my script currently looks like this:

coinsvalue = script.Parent

game.Players.PlayerAdded:Connect(function(player)
while true do
coinsvalue.Text = player.leaderstats.Coins.Value
wait(0.5)
end
end)

So my question basically is: How do I set the text of a textlabel to the value of a leaderstat?

Sorry if my question is a bit unclear, I'm not english, Im 13 years old and i don't know how to word it.

Thanks for reading.

0
Did you get any errors? Press f9 in game or open the console in studio. Torren_Mr 334 — 4y

2 answers

Log in to vote
2
Answered by 4 years ago

The script is good, but you cannot set an IntValue to a String, you need to convert it first using tostring()

coinsvalue = script.Parent

game.Players.PlayerAdded:Connect(function(player)
    while true do
        coinsvalue.Text = tostring(player.leaderstats.Coins.Value)

        wait(0.5)
    end
end)
0
Best answer ^^ Sulu710 142 — 4y
Ad
Log in to vote
0
Answered by
harstud 218 Moderation Voter
4 years ago

This may work, make sure you have a leaderstats.

coinsvalue = script.Parent

game.Players.PlayerAdded:Connect(function(player)
    while wait() do
        coinsvalue.Text = player.leaderstats.Coins.Value
    end
end)

Answer this question