local spawns = game.Workspace:FindFirstChild("Spawns") local function onPlayerAdded(player) -- buat leaderstats local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local stage = Instance.new("IntValue") stage.Name = "Stage" stage.Value = 1 -- Default stage awal stage.Parent = leaderstats -- karakter muncul player.CharacterAdded:Connect(function(character) local humanoid = character:FindFirstChild("Humanoid") -- Check point sesuai stage if humanoid then humanoid.Died:Connect(function() task.wait(2) local playerStage = stage.Value local spawnPosition = nil if spawns then for _, checkpoint in pairs(spawns:GetChildren()) do if checkpoint:IsA("Part") and checkpoint.Name == "Checkpoint" then local stageValue = checkpoint:FindFirstChild("Stage") if stageValue and stageValue:IsA("IntValue") and stageValue.Value == playerStage then spawnPosition = checkpoint.Position + Vector3.new(0, 3, 0) break end end end end -- teleport checkpoint terakhir if spawnPosition then player.CharacterAdded:Wait() task.wait(0.5) player.Character:SetPrimaryPartCFrame(CFrame.new(spawnPosition)) end end) end end) end game.Players.PlayerAdded:Connect(onPlayerAdded)