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

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

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.

1 comment

0

Did you get any errors? Press f9 in game or open the console in studio.

2 answers

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)

1 comment

0

Best answer ^^

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)

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