Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.