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

The Value won't update the text?

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

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.

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