Skip to content

Instantly share code, notes, and snippets.

@ohusq
Last active February 8, 2025 15:25
Show Gist options
  • Save ohusq/e1b1d99dd4e1d80c824511166d59217a to your computer and use it in GitHub Desktop.
Save ohusq/e1b1d99dd4e1d80c824511166d59217a to your computer and use it in GitHub Desktop.
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local leaderstatsFolder = Instance.new("Folder")
leaderstatsFolder.Name = "leaderstats"
leaderstatsFolder.Parent = player
local cash = Instance.new("NumberValue")
cash.Name = "Cash"
cash.Parent = leaderstatsFolder
cash.Value = 50
end)
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
while task.wait(5) do -- Delay for 5 seconds for each time money gets added
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then -- Check if leaderstats is inside of the player
local money = leaderstats:FindFirstChild("Cash")
if money then -- "Checks if money exists"
money.Value = money.Value + 1000 -- Add 1000 money
else
warn("Couldn't find the 'Cash' leaderstat, probably because your object name for money is different") -- Pops up if it can't find your money object
end
end
end
end)
game:GetService("Players").YOURUSERNAME.leaderstats.Cash.Value = 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment