Here is your server script
local dataStoreService = game:GetService("DataStoreService")
local PlayerService = game:GetService("Players")
local stageStore = dataStoreService:GetDataStore("PlayerStageDataStore")
local Checkpoints = workspace:WaitForChild("Checkpoints", 30)
function plrToStage(plr)
repeat wait() until plr.Character.HumanoidRootPart
local stagePart = game.Workspace.Checkpoints:FindFirstChild(tostring(plr.leaderstats.Stage.Value))
plr.Character.HumanoidRootPart.CFrame = stagePart.CFrame + Vector3.new(0,2.5,0)
end
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Parent = leaderstats
local success, errorMsg = pcall(function()
stage.Value = stageStore:GetAsync(player.UserId)
end)
if success then
print("Successfully got "..player.Name.."'s stage data.")
else
warn(errorMsg)
end
if player.Character then
plrToStage(player)
end
player.CharacterAdded:Connect(function()
plrToStage(player)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMsg = pcall(function()
stageStore:SetAsync(player.UserId,player.leaderstats.Stage.Value)
end)
if success then
print("Successfully saved"..player.Name.."'s stage data.")
else
warn(errorMsg)
end
end)
for i, Child in pairs(Checkpoints:GetChildren()) do
Child.Touched:Connect(function(Hit)
local Player = PlayerService:GetPlayerFromCharacter(Hit.Parent)
local Humanoid = Hit.Parent:FindFirstChildWhichIsA("Humanoid")
if Player and Humanoid then
local leaderstats = Player and Player:FindFirstChild("leaderstats")
local Stage = leaderstats and leaderstats:FindFirstChild("Stage")
local Number = tonumber(Child.Name)
if Stage and Stage.Value < Number then
Stage.Value = Number
end
end
end)
end