local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("coinsDataStore") game.Players.PlayerAdded:Connect(function(plr) local data local success,errormessage = pcall(function() data = DataStore:GetAsync(plr.UserId.."-data") if data then else data = {0,1} end print("Got data") end) if success then print("Yay") else print(errormessage) end local leaderstats = Instance.new("Folder",plr) leaderstats.Name = "leaderstats" local checkpoints = Instance.new("IntValue",leaderstats) checkpoints.Name = "Stage" if data[2] then checkpoints.Value = data[2] else checkpoints.Value = 1 end local coins = Instance.new("IntValue",leaderstats) coins.Name = "Coins" if data[2] then coins.Value = data[1] else coins.Value = 0 end plr.CharacterAdded:Connect(function(Character) repeat wait() until plr.Character ~= nil local checkpoint = workspace.Stages:FindFirstChild(checkpoints.Value) Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.Position + Vector3.new(0,2,0)) end) end) game.Players.PlayerRemoving:Connect(function(plr) local id = plr.userId local checkpoints = plr.leaderstats.Stage.Value local coins = plr.leaderstats.Coins.Value local data = {coins,checkpoints} local success,errormessage = pcall(function() DataStore:SetAsync(plr.UserId.."-data",data) end) if success then print("Yay") else print(errormessage) end end)
I am trying to get the datastore but it seems it doesn't load in. I have API services in Studio.