- gem spillet
- gå til settings
- gå til security
- slå api services til
- lav en script i serverScriptService
- put den her script i
local DataStoreService = game:GetService("DataStoreService") -- geting dataStoreService
local dataStore = DataStoreService:GetDataStore("datastore") -- geting a datastore
local starterCash = 0 -- change this to the starter cash
local cashName = "Cash" -- change this to your value name
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Cash = Instance.new("IntValue", leaderstats)
Cash.Name = cashName
Cash.Value = dataStore:GetAsync(player.UserId) or starterCash -- getting a players data
Cash.Changed:Connect(function()
dataStore:SetAsync(player.UserId, Cash.Value) -- saves every time the value's value change
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
dataStore:SetAsync(player.UserId, player.leaderstats:FindFirstChild(cashName).Value) -- save every time a player is leaving
end)