Hi, I’m pretty new at scripting, I wanted to create a 2d adventure-like game where you collect a certain amount of coins to get to the next level.
The issue is that when the player collects the coin, the NumberValue does change, but, the text in the top left corner doesn’t. Here is the script for the text label:
local cvalue = game.Workspace.Value.Value -- Coin Value
while wait() do
script.Parent.Text = cvalue.. " coins" -- Text indicator
end
I’ve tried many solutions, but I’ve forgotten most of them… 
1 Like
If the title is wrong, I’m sorry. I don’t really know how to call this
It’s because you made it already set the value into a variable, which by default at the start of the game would be 0/the value you set as the default, it will never retrieve the new value because the varaible already has the current value set to it, the Simplest fix would be to store the NumberValue in the variable get the .Value directly
local cvalue = game.Workspace.Value -- Coin Value
while wait() do
script.Parent.Text = cvalue.Value.. " coins" -- Text indicator
end
But .Changed can do what you want without a while loop, which is more optimal
local cvalue = game.Workspace.Value
cvalue.Changed:Connect(function(newval)
script.Parent.Text = newval.." coins"
end)
1 Like