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
6 years ago
Edited 6 years ago
local player = game.Players.LocalPlayer
local cash = player.leaderstats.Cash

while true do
  wait()
  script.Parent.Text = "Cash: "..cash.Value
end

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 — 6y

1 answer

Log in to vote
3
Answered by 6 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;

local player = game.Players.LocalPlayer
local cash = player:WaitForChild("leaderstats").cash
local textlabel = script.Parent

textlabel.Text = cash.Value --When player joins they need to see their cash

cash.Changed:connect(function(Value) --FUNCTIONS WHEN CASH IS CHANGED
    textlabel.Text = cash.Value
end)

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

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

Answer this question