local y=game.Workspace.Targets RideManager.EndCondition={ReachedEnd="\089\111\117 \119\105\110\033",PlatformDeath="\089\111\117 \108\111\115\116\033"}local function J(J)for y,J in ipairs(y:GetChildren())do J:Destroy()end for y,J in ipairs(spawnerFolder:GetChildren())do local K=J:WaitForChild("\073\115\065\099\116\105\118\101")K.Value=false end for y,J in ipairs(J:GetDescendants())do if J:IsA("\080\097\114\116\105\099\108\101\069\109\105\116\116\101\114")then J.Enabled=false end end end function RideManager.setupRide(K,y,J)local l=(y:WaitForChild("\068\097\116\097")):WaitForChild("\072\105\116\112\111\105\110\116\115")l.Value=GameSettings.PlatformHealthDifficulty[J]local d=(y:WaitForChild("\068\097\116\097")):WaitForChild("\079\114\105\103\105\110\097\108\080\111\115");(y:WaitForChild("\080\114\105\109\097\114\121\080\097\114\116")).CFrame=CFrame.new(d.Value)end function RideManager.endRide(K,y)isGameActive.Value=false PlayerManager.removePlayersFromGame()J(y)end return RideManager
-- Folder where enemies are parented to upon spawning
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
