Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't my table in DataStore saving?

Asked by 3 years ago
Edited 3 years ago

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.

0
IF its server you don't need to use wait for child marine5575 359 — 3y
0
It is in the server, but it still doesn't seem to save CrypxticDoge 135 — 3y

Answer this question