Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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?

0
Never mind I got it working JoshGamingHQ1 43 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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.

0
I already fixed my issue, but thanks! JoshGamingHQ1 43 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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.

Answer this question