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

|SOLVED |I dont know why my text GUI isnt updating through script?

local player = game:GetService("Players").LocalPlayer
FUNDSAMOUNT = player.Backpack.AmountOfMoney.Value
FUNDSVIEW = script.Parent.FUNDS.Text


wait(1)
player.Backpack.AmountOfMoney.Changed:Connect(function()
	game.Players.LocalPlayer.PlayerGui.Funds.FUNDS.Text = "$"..FUNDSAMOUNT
end)


if FUNDSAMOUNT >999 then 
	script.Parent.FUNDS.Text = "$"..FUNDSAMOUNT.."K"
else
	script.Parent.FUNDS.Text = "$"..FUNDSAMOUNT
end

if FUNDSAMOUNT >999999 and FUNDSAMOUNT <1000000000 then
	script.Parent.FUNDS.Text = "$"..FUNDSAMOUNT.."M"
else

end

I really dont know why this isnt working. I can print the value but cant print or change the text.

1 answer

✓ Accepted answer

The if statements need to be called when the funds amount changes otherwise they'll only run one time.

Don't put .Value or .text on the end of variables, and make sure you're using local.

Edit: Also if you're gonna make variables make sure you use them. Lots of wasted time spent typing things out that could've been saved.

local player = game:GetService("Players").LocalPlayer
local FUNDSAMOUNT = player.Backpack.AmountOfMoney
local FUNDSVIEW = script.Parent.FUNDS

wait(1)

FUNDSAMOUNT.Changed:Connect(function()
	game.Players.LocalPlayer.PlayerGui.Funds.FUNDS.Text = "$"..FUNDSAMOUNT.Value
-- ^^^^ im not totally sure what you're trying to do here so I left it alone
	if FUNDSAMOUNT > 999 then 
		FUNDSVIEW.Text = "$"..FUNDSAMOUNT.Value.."K"
	else
		FUNDSVIEW.Text = "$"..FUNDSAMOUNT.Value
	end

	if FUNDSAMOUNT > 999999 and FUNDSAMOUNT < 1000000000 then
		FUNDSVIEW.Text = "$"..FUNDSAMOUNT.Value.."M"
	end
end)

5 comments

0

Alright that script worked but now it only updates when the value manually updates. Ive tried to change it through script but nothing seems to work.

0

I dont follow what you mean. How was the AmountOfMoney value created, by the server or client? However it was created is how it must be changed or the change wont be replicated.

0

If you used a leaderstats style script to make the "AmountOfMoney" value then you need to change that value with a server script, this is a local script and it wont work without using a remote event.

0

I think im just gonna redo the entire money system in leaderstats.

0

If i've answered your question please accept.

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