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

How would I make someone's amount of money print on a GUI's TextLabel?

Code I have so far:

game.Players.PlayerAdded:Connect(function()
	game.StarterGui:FindFirstChild("Money")
	if Money.Value == 0 then 
		game.StarterGui.MoneyGUI.MoneyFrame.MoneyText.Text = ("'No world means NO MONEY!' -Mr. Krabs")
	elseif game.Players.Money > 0 then
		game.StarterGui.MoneyGUI.MoneyFrame.MoneyText.Text = game.Players.Money		
	end 
end)

It doesn't work. It leaves the TextLabel (MoneyText) saying 'Label'. What am I doing wrong? Shouldn't its text change to 'No world means NO MONEY! -Mr Krabs'?

1 answer

✓ Accepted answer

I'm a bit confused. You did Money.Value == 0 but on the second argument, you used game.Players.Money > 0? On the second one, you are checking inside of the Player directory. And the StarterGui is the wrong directory. If you want to change a GUI text you need to change the one located in PlayerGui. Here's some code that should help you a bit.

game.Players.PlayerAdded:Connect(function(Player)
    local PlayerGui = Player:WaitForChild("PlayerGui")
	local Money = Player:WaitForChild("Money")
	local MoneyGUI = PlayerGui:WaitForChild("MoneyGUI")
    if Money.Value <= 0 then 
        MoneyGUI.MoneyFrame.MoneyText.Text = ("'No world means NO MONEY!' -Mr. Krabs")
    else
        MoneyGUI.MoneyFrame.MoneyText.Text = Money.Value   
    end 
end)

That won't automatically update though. And that is assuming the Money is located inside of the player and not in a different folder.

1 comment

0

I think on the second argument I forgot to put Value after money

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