I want it so there is no cash stat in the leaderboard but to have it just in the GUI The scripts: Serverscript:
01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | local leaderstats = Instance.new( "Folder" ) |
03 | leaderstats.Parent = plr |
04 | leaderstats.Name = "leaderstats" |
05 |
06 | local cash = Instance.new( "IntValue" ) |
07 | cash.Parent = leaderstats |
08 | cash.Name = "Cash" |
09 |
10 | cash.Value = 0 |
11 |
12 | while wait( 60 ) do |
13 | cash.Value = cash.Value + 50 |
14 | end |
15 | end ) |
The local script:
1 | local textLabel = script.Parent.Frame.TextLabel |
2 | local cash = game.Players.LocalPlayer.leaderstats.Cash |
3 |
4 | cash.Changed:Connect( function () |
5 | textLabel.Text = "Cash: " ..cash.Value |
6 | end ) |
Server Script (using a datastore script i made for a previous game):
01 | local datastore = game:GetService( "DataStoreService" ) |
02 | local players = game:GetService( "Players" ) |
03 | local getMoney = datastore:GetDataStore( "money" ) |
04 | local money = Instance.new( "IntValue" ) |
05 |
06 | local function onPlayerAdded(player) |
07 | local playerKey = "Player_" .. player.UserId |
08 |
09 | local stats = Instance.new( "IntValue" ) |
10 | stats.Name = "Stats" |
11 |
12 | money.Name = "Money" |
13 | money.Parent = player |
14 | end |
15 |
Local Script
1 | local player = game.LocalPlayer.Name |
2 | local textLabel = script.Parent.Frame.TextLabel |
3 | local cash = game.Workspace [ player ] .Money |
4 |
5 | cash.Changed:Connect( function () |
6 | cash.Text = "Cash: " ..cash.Value |
7 | end ) |