Hello, I want to know what is wrong with the script. Why do spawners work only on one map, and the code throws an error on other maps
Here is some paths:
Here is the code:
local RS = game:GetService("ReplicatedStorage")
local GearFolder = RS:WaitForChild("Gears"):GetChildren()
local MapHolder = RS:WaitForChild("MapHolder")
function chooseSpawn()
for i,v in pairs(MapHolder:GetChildren()) do
local FindMapinWorkspace = game.Workspace:FindFirstChild(v.Name)
local spawns = FindMapinWorkspace.SpawnFolder:GetChildren()
if spawns then
local _Spawn = spawns[math.random(1,#spawns)]
return _Spawn
end
end
end
local function chooseItem ()
local item = GearFolder[math.random(1,#GearFolder)]
return item
end
while task.wait(5) do
local _spawn = chooseSpawn()
local item = chooseItem()
local clone = item:Clone()
clone.Parent = game.Workspace
clone.Handle.CFrame = _spawn.CFrame * CFrame.new(0,5,0)
end