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

So I have this script where the GUI says the cash amount that the leaderstat says?

Asked by 4 years ago

I want it so there is no cash stat in the leaderboard but to have it just in the GUI The scripts: Serverscript:

01game.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
15end)

The local script:

1local textLabel = script.Parent.Frame.TextLabel
2local cash = game.Players.LocalPlayer.leaderstats.Cash
3 
4cash.Changed:Connect(function()
5    textLabel.Text = "Cash: "..cash.Value
6end)

1 answer

Log in to vote
0
Answered by
KingDomas 153
4 years ago

Server Script (using a datastore script i made for a previous game):

01local datastore = game:GetService("DataStoreService")
02local players = game:GetService("Players")
03local getMoney = datastore:GetDataStore("money")
04local money = Instance.new("IntValue")
05 
06local 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
14end
15 
View all 25 lines...

Local Script

1local player = game.LocalPlayer.Name
2local textLabel = script.Parent.Frame.TextLabel
3local cash = game.Workspace[player].Money
4 
5cash.Changed:Connect(function()
6    cash.Text = "Cash: "..cash.Value
7end)
Ad

Answer this question