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

How to display money in textlabel?

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
if leaderstats then
	print(leaderstats)
	local MoneyValue = leaderstats:WaitForChild("Money")
	if MoneyValue then
		script.Parent.Text = MoneyValue .. "$"
	end	
end

its not working and not printing it and i don't know why

1 answer

I found multiple errors in your code. Also you was trying to print an Instance and you weren't updating the UI.

Here is the fixed code:

local player = game.Players.LocalPlayer 

local leaderstats = player:WaitForChild("leaderstats") 
 while wait(0.01) do
  if leaderstats then
     script.Parent.Text = leaderstats.Money.Value.."$"
end
end

4 comments

0

Still says "Players.MrBucketOfficial.PlayerGui.ScreenGui.TextLabel.Script:1: attempt to index nil with 'WaitForChild' "

0

If the textlabel works, then ignore it. That happens because the script was activated first before the gane finished loading. That’s a common thing. If it doesn’t work klet me know and I might give a solution.

0

game*

0

It must be in a localscript

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