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

Hey I need help on my MoneyGUI for the textlabel?

Asked by 4 years ago
Edited 4 years ago

So I need my textLabel To say the amount of cash a person has aswell as that cash going up by 50 every minute My current script is:

local Cash = game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").Cash
local textLabel = script.Parent.Frame.TextLabel

Cash.Changed:Connect(function()
    Cash.Value = 0
    wait(60)
    Cash.Value = Cash.Value + 50
    textLabel.Text = tostring(Cash.Value)
end)

0
NNOw its local Cash = script.WaitForChild().leaderstats.Cash Cash.Changed:connect(function() script.Parent.Text = Cash.Value Cash.Value = 0 wait(60) Cash.Value = Cash.Value + 50 end) SDvacation10 21 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

BIG Edit: After speaking with the person who asked the question, I reworked the answer. First of all, you need to create leaderstats, since you don't have one. Here's how you create it. Firstly, you need a server script in order to create the leaderstats.

--Server Script. Put this on ServerScriptService.
game.Players.PlayerAdded:Connect(function(plr) --plr is the parameter. New player, basically.
    local leaderstats = Instance.new("Folder")  --Folder can allow to cram IntValues, etc.
    leaderstats.Parent = plr  --leaderstats will be the child of plr
    leaderstats.Name = "leaderstats" --Name.

    local cash = Instance.new("IntValue")
    cash.Parent = leaderstats
    cash.Name = "Cash"

    cash.Value = 0

    while wait(60) do
        cash.Value = cash.Value + 50
    end
end)

Now I made the leaderstats. Now we need the GUI.

--LocalScript. Put this under ScreenGui
local textLabel = script.Parent.Frame.TextLabel
local cash = game.Players.LocalPlayer.leaderstats.Cash

cash.Changed:Connect(function()
    textLabel.Text = "Cash: "..cash.Value
end)
Ad

Answer this question