local q=script.Parent local R=nil local Y=Region3.new(Vector3.new(q.Position.X-q.Size.X/2,q.Position.Y+q.Size.Y/2,q.Position.Z-q.Size.Z/2),Vector3.new(q.Position.X+q.Size.X/2,q.Position.Y+4,q.Position.Z+q.Size.Z/2))local h=game.Workspace:FindPartsInRegion3(Y)for q,Y in pairs(h)do if Y and(Y.Parent and Y.Parent:IsA("\084\111\111\108"))then R=Y.Parent break end end local X=q.Configurations local P={}local function B(q,R)if X:FindFirstChild(q)then P[q]=(X:FindFirstChild(q)).Value else P[q]=R end end B("\083\112\097\119\110\067\111\111\108\100\111\119\110",5)if R then R.Parent=game.ServerStorage while true do local q=R:Clone()local Y=q:FindFirstChild("\072\097\110\100\108\101")q.Parent=game.Workspace local h=true local X X=q.AncestryChanged:connect(function()if Y then Y.Anchored=false end h=false X:disconnect()end)if Y then print("\114\101\109\111\118\101\100 \115\112\105\110")Y.Anchored=true end while h do if Y then print("\114\101\109\111\118\101\100 \115\112\105\110\110\105\110\103")end wait()end wait(P.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 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
			print("removed spin")
			handle.Anchored = true
		end
		-- wait for tool to be removed
		while toolOnPad do 
			if handle then
				print("removed spinning")
			end
			wait() 
		end
		
		-- wait for cooldown
		wait(configs["SpawnCooldown"])		
	end
	
end


