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

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