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:
1 | local Cash = game:GetService( "Players" ).LocalPlayer:WaitForChild( "leaderstats" ).Cash |
2 | local textLabel = script.Parent.Frame.TextLabel |
3 |
4 | Cash.Changed:Connect( function () |
5 | Cash.Value = 0 |
6 | wait( 60 ) |
7 | Cash.Value = Cash.Value + 50 |
8 | textLabel.Text = tostring (Cash.Value) |
9 | end ) |
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. |
02 | game.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 |
16 | end ) |
Now I made the leaderstats. Now we need the GUI.
1 | --LocalScript. Put this under ScreenGui |
2 | local textLabel = script.Parent.Frame.TextLabel |
3 | local cash = game.Players.LocalPlayer.leaderstats.Cash |
4 |
5 | cash.Changed:Connect( function () |
6 | textLabel.Text = "Cash: " ..cash.Value |
7 | end ) |