local t=script.Parent local N=nil local M=Region3.new(Vector3.new(t.Position.X-t.Size.X/2,t.Position.Y+t.Size.Y/2,t.Position.Z-t.Size.Z/2),Vector3.new(t.Position.X+t.Size.X/2,t.Position.Y+4,t.Position.Z+t.Size.Z/2))local p=game.Workspace:FindPartsInRegion3(M)for t,M in pairs(p)do if M and(M.Parent and M.Parent:IsA("\084\111\111\108"))then N=M.Parent break end end local L=t.Configurations local f={}local function I(t,N)if L:FindFirstChild(t)then f[t]=(L:FindFirstChild(t)).Value else f[t]=N end end I("\083\112\097\119\110\067\111\111\108\100\111\119\110",5)if N then N.Parent=game.ServerStorage while true do local M=N:Clone()local p=M:FindFirstChild("\072\097\110\100\108\101")M.Parent=game.Workspace local L=true local I I=M.AncestryChanged:connect(function()if p then p.Anchored=false end L=false I:disconnect()end)if p then p.CFrame=(t.CFrame+Vector3.new(0,p.Size.Z/2+1,0))*CFrame.Angles(-math.pi/2,0,0)p.Anchored=true end while L do if p then p.CFrame=p.CFrame*CFrame.Angles(0,0,math.pi/60)end wait(10)end wait(f.SpawnCooldown)end end
-- See if I have a tool
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 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(10)
		end

		-- wait for cooldown
		wait(configs["SpawnCooldown"])
	end
end
