I have this script:
Cash.Changed:connect(function() Label.Text = '$'..tostring(Cash.Value) end)
Should I put this in a local script or just a script?
Is there anything I need to add to the script to make the money GUI work?
Local scripts are usually what you want to use in a Gui
, especially withFiltering Enabled
on.
Assuming this is your hierarchy, then here is the following code;
I have set up two variables
to define the location of both the TextLabel, and the Points.
local Label = game.Players.LocalPlayer.PlayerGui.ScreenGui:FindFirstChild('TextLabel') local Cash = game.Players.LocalPlayer.leaderstats:FindFirstChild('Points')
I am connecting to the event, .Changed
, the function will run once the IntValue has changed.
Cash.Changed:Connect(function()
Now because the IntValue
was .Changed
, the Label will update itself to whatever the Cash.Value
is equal to.
Label.Text = '$'..tostring(Cash.Value) end)
Full code;
local Label = game.Players.LocalPlayer.PlayerGui.ScreenGui:FindFirstChild('TextLabel') local Cash = game.Players.LocalPlayer.leaderstats:FindFirstChild('Points') Cash.Changed:Connect(function() Label.Text = '$'..tostring(Cash.Value) end)
This code should be in a localscript
.
Also, It has been pointed out to me that instead of :connect
, you should be using :Connect
as it has since been deprecated. The same thing with the signal events, disconnect
and wait
.
Hope this helps! Don't forget to accept my answer if this works for you, or leave a comment if you need further assistance!