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:

1local Cash = game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").Cash
2local textLabel = script.Parent.Frame.TextLabel
3 
4Cash.Changed:Connect(function()
5    Cash.Value = 0
6    wait(60)
7    Cash.Value = Cash.Value + 50
8    textLabel.Text = tostring(Cash.Value)
9end)
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.

01--Server Script. Put this on ServerScriptService.
02game.Players.PlayerAdded:Connect(function(plr) --plr is the parameter. New player, basically.
03    local leaderstats = Instance.new("Folder"--Folder can allow to cram IntValues, etc.
04    leaderstats.Parent = plr  --leaderstats will be the child of plr
05    leaderstats.Name = "leaderstats" --Name.
06 
07    local cash = Instance.new("IntValue")
08    cash.Parent = leaderstats
09    cash.Name = "Cash"
10 
11    cash.Value = 0
12 
13    while wait(60) do
14        cash.Value = cash.Value + 50
15    end
16end)

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

1--LocalScript. Put this under ScreenGui
2local textLabel = script.Parent.Frame.TextLabel
3local cash = game.Players.LocalPlayer.leaderstats.Cash
4 
5cash.Changed:Connect(function()
6    textLabel.Text = "Cash: "..cash.Value
7end)
Ad

Answer this question