local T=game.Workspace.Targets RideManager.EndCondition={ReachedEnd="\089\111\117 \119\105\110\033";PlatformDeath="\089\111\117 \108\111\115\116\033"}local function G(G)for T,G in ipairs(T:GetChildren())do G:Destroy()end for T,G in ipairs(spawnerFolder:GetChildren())do local o=G:WaitForChild("\073\115\065\099\116\105\118\101")o.Value=false end for T,G in ipairs(G:GetDescendants())do if G:IsA("\080\097\114\116\105\099\108\101\069\109\105\116\116\101\114")then G.Enabled=false end end end function RideManager.setupRide(o,T,G)local H=(T:WaitForChild("\068\097\116\097")):WaitForChild("\072\105\116\112\111\105\110\116\115")H.Value=GameSettings.PlatformHealthDifficulty[G]local y=(T:WaitForChild("\068\097\116\097")):WaitForChild("\079\114\105\103\105\110\097\108\080\111\115");(T:WaitForChild("\080\114\105\109\097\114\121\080\097\114\116")).CFrame=CFrame.new(y.Value)end function RideManager.endRide(o,T)isGameActive.Value=false PlayerManager.removePlayersFromGame()G(T)end return RideManager

local enemyFolder = game.Workspace.Targets

RideManager.EndCondition = {
	ReachedEnd = "You win!",
	PlatformDeath = "You lost!"
}

local function resetRide(platformObject)
	-- Destroy any remaining enemies
	for _, enemy in ipairs(enemyFolder:GetChildren()) do
		enemy:Destroy()
	end
	
	-- Deactivate all enemy spawners
	for _, spawner in ipairs(spawnerFolder:GetChildren()) do
		local isActive = spawner:WaitForChild("IsActive")
		isActive.Value = false
	end
	
	-- Deactivate effects on the platform 	
	for _, object in ipairs(platformObject:GetDescendants()) do
		if object:IsA("ParticleEmitter") then
			object.Enabled = false
		end
	end
end

function RideManager:setupRide(platformObject, difficulty)
	local hitpoints = platformObject:WaitForChild("Data"):WaitForChild("Hitpoints")
	hitpoints.Value = GameSettings.PlatformHealthDifficulty[difficulty]
	
	local positionToSet = platformObject:WaitForChild("Data"):WaitForChild("OriginalPos")
	platformObject:WaitForChild("PrimaryPart").CFrame = CFrame.new(positionToSet.Value)
end

function RideManager:endRide(platformObject)
	isGameActive.Value = false	
	PlayerManager.removePlayersFromGame()
	resetRide(platformObject)
end

return RideManager
