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

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

Asked by 7 years ago

Here is my script, Please help me!

01--Variables
02local plr = game.Players.LocalPlayer
03local cash = script.Parent.Cash.Value
04local show = script.Parent
05 
06--Script
07while (1) do
08    show.Text = cash
09    print(cash)
10    wait(0.1)
11end

4 answers

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
7 years ago

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?

Ad
Log in to vote
1
Answered by
caoshen 96
7 years ago

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:

1show.Text = cash.Value

I hope that helped!

Log in to vote
0
Answered by 7 years ago

What you are doing will never work so instead do this

1local plr = game.Players.LocalPlayer
2local cash = script.Parent.Cash.Value
3local show = script.Parent
4 
5script.Parent.Cash.Changed:connect(function()
6show.Text = cash
7print(cash)
8wait(0.1)
9end)
Log in to vote
0
Answered by 7 years ago

Thx so much it worked!

Answer this question