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

Why is the Textlabels I have not changing text?

Asked by 6 years ago
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

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

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. hiimgoodpack 2009 — 6y
0
Yeah before you posted this answer I realized it thanks though! I will accept duckyo011 36 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
while true do
    coinsgui.Text = "Coins - " .. coins.Value
    LevelGUI.Text = "Level - " ..Level.Value
    gemGUI.Text = "Gems - " ..gems.Value
end
0
Doesn't explain anything. hiimgoodpack 2009 — 6y
0
while wait() do PyccknnXakep 1225 — 6y
Log in to vote
-1
Answered by 6 years ago

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!

Answer this question