Hey, so I’m trying to make different animals spawn which are in a folder I hold in ServerStorage and its working but the problem is that, Im picking two random animals from the folder, and I have two in there but when it picks the same animal twice it only puts one in workspace but when its different ones it works flawlessly
WORKS ( Spawns 1 of each animal ) :
Doesnt work ( Spawns animal only once ):
Code :
local animalsFolder = game.ServerStorage.animals:GetChildren()
local randomSpawns = game.Workspace:FindFirstChild("defaultMap").animalSpawns:GetChildren()
local function placeRandomly(obj,pos)
obj.Parent = workspace
obj:SetPrimaryPartCFrame(pos)
print("Spawned "..obj.Name)
end
placeRandomly(animalsFolder[math.random(1,#animalsFolder)],randomSpawns[math.random(1,#randomSpawns)].CFrame)
placeRandomly(animalsFolder[math.random(1,#animalsFolder)],randomSpawns[math.random(1,#randomSpawns)].CFrame)