Hello! I recently got hired to make a DCO (Difficulty Chart Obby) and I said that I would build and script. The owner made a checkpoint autosave system and it doesn’t work correctly. I can’t figure out what’s wrong. I am on stage 49 (we only have 49 stages so far) and the error is "49 is not a valid member of Folder “Workspace.Checkpoints”. It saves the stages on the leaderboard but doesn’t load them in upon joining. Also, it spawns the player at a random checkpoint instead of the last one that got touched.
Here is the script:
local DS = game:GetService("DataStoreService"):GetDataStore("StageSave") local function OnCharacterAdded(char) game:GetService("RunService").Stepped:Wait() local plr = game.Players:GetPlayerFromCharacter(char) char:WaitForChild("HumanoidRootPart").CFrame = workspace.Checkpoints[tostring(plr.TeleportedStage.Value)].CFrame + Vector3.new(0,3.25,0) end function OnPlayerAdded(plr) plr.CharacterAdded:Connect(OnCharacterAdded) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = plr local stage = Instance.new("IntValue") stage.Name = "Stage" stage.Parent = stats local TeleStage = Instance.new("IntValue") TeleStage.Name = "TeleportedStage" TeleStage.Parent = plr local key = "id_" .. plr.userId local data = DS:GetAsync(key) if data then stage.Value = data TeleStage.Value = stage.Value else DS:GetAsync(key, stage) end end game.Players.PlayerAdded:Connect(OnPlayerAdded) function OnPlayerRemoved(plr) local key = "id_" .. plr.userId local data = plr.leaderstats.Stage.Value DS:SetAsync(key, data) end game.Players.PlayerRemoving:Connect(OnPlayerRemoved)
God bless you!