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

I am trying to make a value constantly update but it wont work, How can I do it?

Here is my script, Please help me!

--Variables
local plr = game.Players.LocalPlayer
local cash = script.Parent.Cash.Value
local show = script.Parent

--Script
while (1) do
	show.Text = cash
	print(cash)
	wait(0.1)
end

4 answers

✓ Accepted answer

Actually, this script works fine. May not be the most efficient, but let's be honest, we all did that once. Although the *while wait(1) and then the wait(0.1) seems a bit odd. while wait(1.1) will do the same. New thought: Did you make sure the script is inside a label or textbox?

At the time you define cash, you're explicitly setting it to the Cash's value - it won't update if the value updates, it'll stay at the value it got at that time.

Let's assume cash has a value of 5 when you define it, but it increments - that variable still has a value of 5. In order to overcome this, remove .Value from line 3, and on line 8, in your while loop, change it to:

show.Text = cash.Value

I hope that helped!

What you are doing will never work so instead do this

local plr = game.Players.LocalPlayer
local cash = script.Parent.Cash.Value
local show = script.Parent

script.Parent.Cash.Changed:connect(function()
show.Text = cash
print(cash)
wait(0.1)
end)

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