Sådan laver du en datastore

  1. gem spillet
  2. gå til settings
  3. gå til security
  4. slå api services til
  5. lav en script i serverScriptService
  6. 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)