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

The Cash GUI doesn't change when the player's cash increases, why?

Asked by
phxtn 154
8 years ago
Edited 8 years ago
1local player = game.Players.LocalPlayer
2local cash = player.leaderstats.Cash
3 
4while true do
5  wait()
6  script.Parent.Text = "Cash: "..cash.Value
7end

Are there any mistakes or anything?

I put this script in the textlabel.

0
try putting brackets like this: script.Parent.Text = ( "Cash: "..cash.Value) RequiredModule 38 — 8y

1 answer

Log in to vote
3
Answered by 8 years ago

Using a loop is really bad because I once used too many loops and it crashed. I have been taught the .Changed:connect:function() method.

Make sure this is a local script in the text label;

1local player = game.Players.LocalPlayer
2local cash = player:WaitForChild("leaderstats").cash
3local textlabel = script.Parent
4 
5textlabel.Text = cash.Value --When player joins they need to see their cash
6 
7cash.Changed:connect(function(Value) --FUNCTIONS WHEN CASH IS CHANGED
8    textlabel.Text = cash.Value
9end)

If any other help is needed comment down below. Please upvote and accept answer if helped.

0
Thanks alot :) It works. phxtn 154 — 8y
0
np BlackOrange3343 2676 — 8y
Ad

Answer this question