local q=game:GetService("\080\108\097\121\101\114\115")local U=game:GetService("\083\101\114\118\101\114\083\116\111\114\097\103\101")local Q=require(U.Source.Managers.PlayerManager)return function(U)for q,T in pairs(q:GetPlayers())do if T.Character and T.Character.PrimaryPart then local q=T.Character.PrimaryPart if q:CanSetNetworkOwnership()then q:SetNetworkOwner(nil)end local Q=U.CFrame*CFrame.new(math.random((-U.Size.X*.5)*100,(U.Size.X*.5)*100)/100,3,math.random((-U.Size.Z*.5)*100,(U.Size.Z*.5)*100)/100)q.CFrame=Q if q:CanSetNetworkOwnership()then q:SetNetworkOwner(T)end else local q=Q.getFromPlayer(T)if q and q.status.currentState=="\103\097\109\101"then(q.stateMachine:get()):startSpectating()end end end end
--[[
    Teleports all players to within the specified part
]]
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

local PlayerManager = require(ServerStorage.Source.Managers.PlayerManager)

return function(spawnPart)
	for _, player in pairs(Players:GetPlayers()) do
		if player.Character and player.Character.PrimaryPart then
			local primaryPart = player.Character.PrimaryPart
			if primaryPart:CanSetNetworkOwnership() then
				primaryPart:SetNetworkOwner(nil)
			end

			local cFrame = spawnPart.CFrame
				* CFrame.new(
					math.random(-spawnPart.Size.X * 0.5 * 100, spawnPart.Size.X * 0.5 * 100) / 100,
					3,
					math.random(-spawnPart.Size.Z * 0.5 * 100, spawnPart.Size.Z * 0.5 * 100) / 100
				)

			primaryPart.CFrame = cFrame

			if primaryPart:CanSetNetworkOwnership() then
				primaryPart:SetNetworkOwner(player)
			end
		else
			local serverPlayerComponent = PlayerManager.getFromPlayer(player)

			if serverPlayerComponent and serverPlayerComponent.status.currentState == "game" then
				serverPlayerComponent.stateMachine:get():startSpectating()
			end
		end
	end
end
