Im trying to make an obby with a non-savable checkpoint system. I already got my folder named “Stages” in workspace with all the checkpoints in it. When a player leaves the game, and joins back, they should be spawned at the beginning of the game, not the checkpoint they left off on.
My knowledge in scripting is extremely limited so I’d appreciate any help.
Thanks
Did you take those checkpoints system from Toolbox? Just delete the line that save player’s checkpoint.
or just delete anything that has anything to do with “leaderstats” or datastore
no I did not take anything from toolbox. I dont even have a checkpoint system yet
Yeah but I want the leaderstats
welp you would need a table and insert the checkpoint numbers there, and when you touch a checkpoint (lets say number 5) it would check first if number 5 is in the table, if it is not, then add the checkpoint there and to teleport the player to the checkpoint after respawning, we get the highest number in the table and teleport them to the checkpoint with that number.
it won’t save unless you’re trying to
Isnt a folder with all the stages fine
Just… don’t save it then.
If you don’t want to save the Checkpoint they are at, then don’t include it to the things you are saving.
you can, but a table is better
explain to me how a table is better
Should I just take any checkpoint handler script and just delete anything abut data
it’s literally the same as adding values inside of a folder but faster and less delayed
Ight ima just stick with the folder,
but should I just take any checkpoint handler script and just delete aanything about the data?
just. dont save the checkpoints at all. literally
?? wdym can you please elaborate
dont save them at all to what
your plan in the first place was to not save checkpoints. then don’t save it to leaderstats. don’t add the values to any folder that will get saved to datastore
alright thanks for your help i appreciate it
I have a question,
Should i take any checkpoint script and just remove anything about the data saves
yes
Alright how would I adjust the script that gets rid of anything that saves data
local Players = game:GetService(“Players”)
local DataStoreService = game:GetService(“DataStoreService”)
local RunService = game:GetService(“RunService”)
local ObbyDataStore = DataStoreService:GetDataStore(“ObbyData”)
local checkpoints = game.Workspace.Checkpoints
local FIRST_CHECKPOINT = 1
Players.PlayerAdded:Connect(function(player)
local playerKey = “ID_” … player.UserId
local retrievedData
local success, errorMessage = pcall(function()
retrievedData = ObbyDataStore:GetAsync(playerKey)
end)
if not success and not RunService:IsStudio() then
player:Kick("Error loading data, please rejoin.")
return
end
if not retrievedData then
retrievedData = {}
end
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stageValue = Instance.new("IntValue")
stageValue.Name = "Stage"
stageValue.Value = retrievedData.Stage or FIRST_CHECKPOINT
stageValue.Parent = leaderstats
player.CharacterAdded:Connect(function(character)
wait()
local checkpoint = checkpoints:FindFirstChild(tostring(stageValue.Value))
if checkpoint then
character:WaitForChild("HumanoidRootPart").CFrame = checkpoint.CFrame + Vector3.new(0, 3 + (checkpoint.Size.Y / 2), 0)
end
end)
end)
for i, v in pairs(checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player or not player:FindFirstChild("leaderstats") then
return
end
if player.leaderstats.Stage.Value == tonumber(v.Name) - 1 then
player.leaderstats.Stage.Value = tonumber(v.Name)
end
end)
end
game.Players.PlayerRemoving:Connect(function(player)
if not player:FindFirstChild(“leaderstats”) then
return
end
local playerKey = "ID_" .. player.UserId
local stage = player.leaderstats.Stage.Value
local success, errorMessage = pcall(function()
ObbyDataStore:SetAsync(playerKey, {Stage = stage})
end)
if not success and not RunService:IsStudio() then
warn("Error while saving player data")
end
end)