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

Why is the Textlabels I have not changing text?

local Player = game.Players.LocalPlayer
local leaderstats = Player.leaderstats
local coins = leaderstats.Coins
local gems = leaderstats.Gems
local Level = leaderstats.Level
local coinsgui = script.Parent.Coins
local LevelGUI = script.Parent.Level
local gemsGUI = script.Parent.Gems
while true do
	coinsgui.Text = "Coins - "..coins.. ""
		LevelGUI.Text = "Level - "..Level.. ""
		gemsGUI.Text = "Gems - "..gems.. ""
	wait()
end

3 answers

✓ Accepted answer
local Player = game.Players.LocalPlayer
local leaderstats = Player.leaderstats
local coins = leaderstats.Coins
local gems = leaderstats.Gems
local Level = leaderstats.Level
local coinsgui = script.Parent.Coins
local LevelGUI = script.Parent.Level
local gemsGUI = script.Parent.Gems
while true do
    coinsgui.Text = "Coins - "..coins.Value.. ""
    LevelGUI.Text = "Level - "..Level.Value.. ""
    gemsGUI.Text = "Gems - "..gems.Value.. ""
    wait()
end

you forgot to put .Value after the stats name, else it tries to name it an instance.

2 comments

0

Why did you put an empty string at the end? Seems like a waste of time...... You should also have put it in a Changed event.

0

Yeah before you posted this answer I realized it thanks though! I will accept

while true do
	coinsgui.Text = "Coins - " .. coins.Value
	LevelGUI.Text = "Level - " ..Level.Value
	gemGUI.Text = "Gems - " ..gems.Value
end

2 comments

0

Doesn't explain anything.

0

while wait() do

What's missing is that you needed to get the value of the leaderstat by using the Value property.

local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins")
local gems = leaderstats:WaitForChild("Gems")
local Level = leaderstats:WaitForChild("Level")
local coinsgui = script.Parent.Coins
local LevelGUI = script.Parent.Level
local gemsGUI = script.Parent.Gems
while wait() do --while wait() do, I don't recommend while true do.
    coinsgui.Text = "Coins - "..coins.Value --You needed to add Value, because how else are you supposed to get how much coins the player has?
        LevelGUI.Text = "Level - "..Level.Value
        gemsGUI.Text = "Gems - "..gems.Value
end

Please accept my answer if this helped you!

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