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

How do I make a GUI that displays the current amount of cash?

I have a GUI that I want to display the amount of cash a player has, but anything I try doesn't show any numbers, just "Text".

The leaderboard script is below.

local players = game:WaitForChild("Players")

local function createLB(player)
    local stats = Instance.new("Folder")
    stats.Name = "leaderstats"
    local coin = Instance.new("IntValue", stats)
    coin.Name = "Coins"
    stats.Parent = player
end

players.PlayerAdded:connect(createLB)

Any suggestions on a script?

1 comment

0

Never mind I got it working

2 answers

✓ Accepted answer

local Player = game.Players.LocalPlayer
local Coins = Player:WaitForChild("leaderstats").Coins

function SetText()
	script.Parent.Text = Coins.Value
end
SetText()
Coins.Changed:Connect(function()
	SetText()
end

Put this script in a local script and put the script within the text label you want. And it should work.

1 comment

0

I already fixed my issue, but thanks!

If anyone has the same issue here, this is the script I used to fix my issue.

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local leaderstats = player:WaitForChild("leaderstats")
local coin = leaderstats.Coins
local value = script.Parent

value.Text = coin.Value

coin:GetPropertyChangedSignal("Value"):Connect(function()
	value.Text = coin.Value
end)

Feel free to use this and change as you wish.

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