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

The Value won't update the text?

Asked by 7 years ago

When I finished the coding I realize when the Value changes, the Text doesn't. I try doing functions,while true do, and looking for people that have the same problem like me. I don't know what do to or know what I was doing.

player = game.Players.LocalPlayer:WaitForChild("leaderstats").Cubes
playerone = game.Players.LocalPlayer:WaitForChild("leaderstats").Level
GameFrame = script.Parent
CubeText = GameFrame:WaitForChild("CubeLabel")


CubeText.Text = "Cubes: " .. player.Value

GameFrame:WaitForChild("LevelLabel").Text = "Lv. " .. playerone.Value

1 answer

Log in to vote
1
Answered by 7 years ago

The best way to solve this is with a function, as you said. The correct event to use in this case is .Changed.

player = game.Players.LocalPlayer:WaitForChild("leaderstats").Cubes
playerone = game.Players.LocalPlayer:WaitForChild("leaderstats").Level
GameFrame = script.Parent
CubeText = GameFrame:WaitForChild("CubeLabel")

player.Value.Changed:connect(function () -- this way, it is updated.
    CubeText.Text = "Cubes: " .. player.Value
end)

playerone.Value.Changed:connect(function () --Likewise here
    GameFrame:WaitForChild("LevelLabel").Text = "Lv. " .. playerone.Value
end)

The reason your code did not work, is because the code was set to only run once, as there was no function.

Ad

Answer this question