I want it so there is no cash stat in the leaderboard but to have it just in the GUI The scripts: Serverscript:
game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Parent = plr leaderstats.Name = "leaderstats" 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)
The local script:
local textLabel = script.Parent.Frame.TextLabel local cash = game.Players.LocalPlayer.leaderstats.Cash cash.Changed:Connect(function() textLabel.Text = "Cash: "..cash.Value end)
Server Script (using a datastore script i made for a previous game):
local datastore = game:GetService("DataStoreService") local players = game:GetService("Players") local getMoney = datastore:GetDataStore("money") local money = Instance.new("IntValue") local function onPlayerAdded(player) local playerKey = "Player_" .. player.UserId local stats = Instance.new("IntValue") stats.Name = "Stats" money.Name = "Money" money.Parent = player end for _, player in pairs(players:GetPlayers()) do onPlayerAdded(player) end players.PlayerAdded:Connect(onPlayerAdded) wait(1) while wait(0.1) do getMoney:SetASync(myMoney) money.Value = tonumber(myMoney) end
Local Script
local player = game.LocalPlayer.Name local textLabel = script.Parent.Frame.TextLabel local cash = game.Workspace[player].Money cash.Changed:Connect(function() cash.Text = "Cash: "..cash.Value end)