<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
<Item class="Workspace" referent="RBX00000001"><Properties><string name="Name">Workspace</string></Properties></Item>
<Item class="ServerScriptService" referent="RBX00000002"><Properties><string name="Name">ServerScriptService</string></Properties>
<Item class="Script" referent="RBX00000003"><Properties><string name="Name">Bootstrap</string><bool name="Disabled">false</bool><ProtectedString name="Source"><![CDATA[-- Lays a baseplate and a spawn so every build has ground to stand on.
local Workspace = game:GetService("Workspace")

if not Workspace:FindFirstChild("Baseplate") then
	local base = Instance.new("Part")
	base.Name = "Baseplate"
	base.Anchored = true
	base.Locked = true
	base.Size = Vector3.new(512, 4, 512)
	base.Position = Vector3.new(0, -2, 0)
	base.Material = Enum.Material.SmoothPlastic
	base.Color = Color3.fromRGB(91, 93, 105)
	base.TopSurface = Enum.SurfaceType.Smooth
	base.Parent = Workspace
end

if not Workspace:FindFirstChildWhichIsA("SpawnLocation", true) then
	local spawn = Instance.new("SpawnLocation")
	spawn.Name = "SpawnLocation"
	spawn.Anchored = true
	spawn.Neutral = true
	spawn.Size = Vector3.new(12, 1, 12)
	spawn.Position = Vector3.new(0, 0.5, 0)
	spawn.Material = Enum.Material.SmoothPlastic
	spawn.Parent = Workspace
end
]]></ProtectedString></Properties></Item>
<Item class="Script" referent="RBX00000004"><Properties><string name="Name">v0.1 Core obby loop with rising volcano slope and lava parts</string><bool name="Disabled">false</bool><ProtectedString name="Source"><![CDATA[local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local ServerScriptService = game:GetService("ServerScriptService")
local Workspace = game:GetService("Workspace")

-- Create main container for obby parts to keep workspace clean
local obbyFolder = Workspace:FindFirstChild("ObbyParts")
if not obbyFolder then
	obbyFolder = Instance.new("Folder")
	obbyFolder.Name = "ObbyParts"
	obbyFolder.Parent = Workspace
end

-- SpawnLocation already exists at origin (v0.1)
local spawnLocation = Workspace:FindFirstChildWhichIsA("SpawnLocation")
if not spawnLocation then
	spawnLocation = Instance.new("SpawnLocation")
	spawnLocation.Position = Vector3.new(0, 5, 0)
	spawnLocation.Size = Vector3.new(6,1,6)
	spawnLocation.Anchored = true
	spawnLocation.CanCollide = true
	spawnLocation.Parent = Workspace
end

-- Leaderstats for stage tracking (starts at 0)
Players.PlayerAdded:Connect(function(player)
	local leaderstats = player:FindFirstChild("leaderstats")
	if not leaderstats then
		leaderstats = Instance.new("Folder")
		leaderstats.Name = "leaderstats"
		leaderstats.Parent = player
	end
	local stage = leaderstats:FindFirstChild("Stage")
	if not stage then
		stage = Instance.new("IntValue")
		stage.Name = "Stage"
		stage.Value = 0
		stage.Parent = leaderstats
	end
end)

-- Constants for obby  
local START_X = 0
local START_Z = 30
local STAGE_HEIGHT = 8
local PLATFORM_SIZE = Vector3.new(10, 1.5, 10)
local PLATFORM_SPACING = 12
local LAVA_LEVEL = 2 -- Y level of lava surface
local NUM_STAGES = 8 -- First chunk towards checkpoint 1 (5+ stages will be later)

-- Create base lava floor spanning far across X and Z under entire first section
local lavaBase = Instance.new("Part")
lavaBase.Name = "LavaBase"
lavaBase.Size = Vector3.new(100, 4, 100)
lavaBase.Position = Vector3.new(0, LAVA_LEVEL - 2, START_Z + (NUM_STAGES * PLATFORM_SPACING)/2)
lavaBase.Anchored = true
lavaBase.BrickColor = BrickColor.new("Bright orange")
lavaBase.Material = Enum.Material.Neon
lavaBase.Parent = obbyFolder
lavaBase.CanCollide = true

-- Touch damage function for lava parts
local function onLavaTouched(hit)
	local character = hit.Parent
	if not character then return end
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid and humanoid.Health > 0 then
		humanoid.Health = 0
	end
end

lavaBase.Touched:Connect(onLavaTouched)

-- Build safe platforms ascending upwards, staggered along Z axis with some X variation
for stage = 1, NUM_STAGES do
	local platform = Instance.new("Part")
	platform.Name = "StagePlatform_" .. stage
	platform.Size = PLATFORM_SIZE
	platform.Anchored = true
	platform.CanCollide = true
	platform.BrickColor = BrickColor.new("Medium stone grey")
	platform.Position = Vector3.new(
		START_X + ((stage % 2 == 0) and 5 or -5),
		STAGE_HEIGHT * stage + 3,
		START_Z + (stage * PLATFORM_SPACING)
	)
	platform.Parent = obbyFolder
end

-- Create small lava hazards (lava "pools") blocking direct path, forcing jumps
for hazardIndex = 1, NUM_STAGES do
	local lavaHazard = Instance.new("Part")
	lavaHazard.Name = "LavaHazard_" .. hazardIndex
	lavaHazard.Size = Vector3.new(8, 3, 8)
	lavaHazard.Anchored = true
	lavaHazard.CanCollide = true
	lavaHazard.Material = Enum.Material.Neon
	lavaHazard.BrickColor = BrickColor.new("Bright red")
	lavaHazard.Position = Vector3.new(
		START_X,
		LAVA_LEVEL + 1,
		START_Z + (hazardIndex * PLATFORM_SPACING) - (PLATFORM_SPACING / 2)
	)
	lavaHazard.Parent = obbyFolder
	lavaHazard.Touched:Connect(onLavaTouched)
end

-- First checkpoint platform above stage 5 (initial checkpoint)
local checkpointStage = 5
local checkpointPlatform = Instance.new("Part")
checkpointPlatform.Name = "CheckpointPlatform"
checkpointPlatform.Size = Vector3.new(15, 1.5, 15)
checkpointPlatform.Anchored = true
checkpointPlatform.CanCollide = true
checkpointPlatform.BrickColor = BrickColor.new("Bright yellow")
checkpointPlatform.Position = Vector3.new(
	START_X,
	STAGE_HEIGHT * checkpointStage + 4,
	START_Z + (checkpointStage * PLATFORM_SPACING) + 5
)
checkpointPlatform.Parent = obbyFolder

-- TouchTrigger to set checkpoint
local checkpointTouch = Instance.new("TouchTransmitter")
checkpointTouch.Parent = checkpointPlatform

local checkpointFolder = Workspace:FindFirstChild("PlayerCheckpoints")
if not checkpointFolder then
	checkpointFolder = Instance.new("Folder")
	checkpointFolder.Name = "PlayerCheckpoints"
	checkpointFolder.Parent = Workspace
end

checkpointPlatform.Touched:Connect(function(hit)
	local character = hit.Parent
	if not character then return end
	local player = Players:GetPlayerFromCharacter(character)
	if player then
		local checkpoints = checkpointFolder:FindFirstChild(player.Name)
		if not checkpoints then
			checkpoints = Instance.new("Folder")
			checkpoints.Name = player.Name
			checkpoints.Parent = checkpointFolder
		end
		local lastCheckpoint = checkpoints:FindFirstChild("LastCheckpoint")
		if not lastCheckpoint then
			lastCheckpoint = Instance.new("Vector3Value")
			lastCheckpoint.Name = "LastCheckpoint"
			lastCheckpoint.Parent = checkpoints
		end
		lastCheckpoint.Value = checkpointPlatform.Position + Vector3.new(0, 5, 0)
		
		-- Update leaderstats stage to checkpointStage since this is the first checkpoint reached
		local leaderstats = player:FindFirstChild("leaderstats")
		if leaderstats then
			local stage = leaderstats:FindFirstChild("Stage")
			if stage then
				stage.Value = math.max(stage.Value, checkpointStage)
			end
		end
	end
end)

-- On player spawning, check for checkpoint saved and place accordingly
Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local checkpoints = checkpointFolder:FindFirstChild(player.Name)
		if checkpoints then
			local lastCheckpoint = checkpoints:FindFirstChild("LastCheckpoint")
			if lastCheckpoint and lastCheckpoint.Value then
				local hrp = character:WaitForChild("HumanoidRootPart", 5)
				if hrp then
					hrp.CFrame = CFrame.new(lastCheckpoint.Value)
				end
				return
			end
		end
		-- default spawn at game spawn location if no checkpoint
		local hrp = character:WaitForChild("HumanoidRootPart", 5)
		if hrp then
			hrp.CFrame = spawnLocation.CFrame + Vector3.new(0, 3, 0)
		end
	end)
end)]]></ProtectedString></Properties></Item>
<Item class="Script" referent="RBX00000005"><Properties><string name="Name">v0.2 Stage 1 Reached</string><bool name="Disabled">false</bool><ProtectedString name="Source"><![CDATA[local Players = game:GetService("Players")

-- Function to set up leaderstats for a player
local function setupPlayer(player)
    -- Check if leaderstats folder already exists, create if not
    local leaderstats = player:FindFirstChild("leaderstats")
    if not leaderstats then
        leaderstats = Instance.new("Folder")
        leaderstats.Name = "leaderstats"
        leaderstats.Parent = player
    end

    -- Check if Stage IntValue already exists, create if not
    local stageStat = leaderstats:FindFirstChild("Stage")
    if not stageStat then
        stageStat = Instance.new("IntValue")
        stageStat.Name = "Stage"
        stageStat.Value = 0 -- Players start at Stage 0
        stageStat.Parent = leaderstats
    end
end

-- Connect setupPlayer to PlayerAdded event for new players
Players.PlayerAdded:Connect(setupPlayer)

-- Apply setupPlayer to players already in the game when this script starts
for _, player in ipairs(Players:GetPlayers()) do
    setupPlayer(player)
end

-- Create a folder to organize obby parts if it doesn't exist
local obbyPartsFolder = workspace:FindFirstChild("ObbyParts")
if not obbyPartsFolder then
    obbyPartsFolder = Instance.new("Folder")
    obbyPartsFolder.Name = "ObbyParts"
    obbyPartsFolder.Parent = workspace
end

-- Create the Stage 1 Marker Part
local stage1MarkerName = "Stage1_Marker"
local stage1Marker = obbyPartsFolder:FindFirstChild(stage1MarkerName)

if not stage1Marker then
    stage1Marker = Instance.new("Part")
    stage1Marker.Name = stage1MarkerName
    stage1Marker.Anchored = true
    stage1Marker.CanCollide = true
    stage1Marker.Size = Vector3.new(10, 1, 10)
    -- Position it clearly visible and reachable after the spawn area.
    -- (0, 0.5, 0) is default SpawnLocation. Place this off-center, slightly up and away.
    stage1Marker.Position = Vector3.new(15, 2.5, -25) 
    stage1Marker.Color = Color3.fromRGB(0, 200, 0) -- Green for a safe platform
    stage1Marker.Material = Enum.Material.Grass
    
    -- Add a text label to the part for clarity
    local surfaceGui = Instance.new("SurfaceGui")
    surfaceGui.Face = Enum.Face.Top
    surfaceGui.LightInfluence = 1
    surfaceGui.Parent = stage1Marker

    local textLabel = Instance.new("TextLabel")
    textLabel.Size = UDim2.new(1, 0, 1, 0)
    textLabel.BackgroundTransparency = 1
    textLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
    textLabel.TextScaled = true
    textLabel.Text = "Stage 1"
    textLabel.Font = Enum.Font.SourceSansBold
    textLabel.Parent = surfaceGui

    stage1Marker.Parent = obbyPartsFolder
end

-- Logic for stage completion when the marker part is touched
local function onStageMarkerTouched(hit)
    local character = hit.Parent
    local player = Players:GetPlayerFromCharacter(character)

    if player then
        local leaderstats = player:FindFirstChild("leaderstats")
        if leaderstats then
            local stageStat = leaderstats:FindFirstChild("Stage")
            -- Check if player's stage is less than 1 to ensure it only increments once for Stage 1
            if stageStat and stageStat.Value < 1 then
                stageStat.Value = 1
            end
        end
    end
end

-- Connect the Touched event for the Stage 1 Marker
stage1Marker.Touched:Connect(onStageMarkerTouched)]]></ProtectedString></Properties></Item>
</Item>
</roblox>