Egg Spawner (on spawn points i made)

Hi, I need help with a spawner. So, what I am supposed to make is to spawn robloxians into the map. I made invisible spawn points and got them into a folder. Then I scripted it so the script gets all the # of robloxians, and randomly spawns them in the map (the invisible spawners i put before).

The problem: It will only drop 1 character and won’t generate even more. Here is the script, I want it to keep generating not stopping after 1 robloxian.
It keeps saying “Position is not a valid member of model.”

local robloxians = game.ReplicatedStorage.Robloxians

local spawns = game.Workspace["Robloxian Spawns"]

while wait(2) do
	
	local robloxianTable = robloxians:GetChildren()
	local randomrobloxians = robloxianTable[math.random(1,#robloxianTable)]
	local spawnsTable = spawns:GetChildren()
	local randomSpawn = spawnsTable[math.random(1,#spawnsTable)]
	
	local robloxianClone = randomrobloxians:Clone()
	robloxianClone.Parent = game.Workspace.SpawnedEggs
	
	robloxianClone.Position = randomSpawn.Position + Vector3.new(0,20,0)
	robloxianClone.Anchored = false
	
	
	
	
end

Models don’t have a position property, so you need to use SetPrimaryPartCFrame()

local robloxians = game.ReplicatedStorage.Robloxians

local spawns = game.Workspace["Robloxian Spawns"]

while wait(2) do
	local robloxianTable = robloxians:GetChildren()
	local randomrobloxians = robloxianTable[math.random(1,#robloxianTable)]
	local spawnsTable = spawns:GetChildren()
	local randomSpawn = spawnsTable[math.random(1,#spawnsTable)]
	
	local robloxianClone = randomrobloxians:Clone()
	robloxianClone:SetPrimaryPartCFrame(CFrame.new(randomSpawn.Position + Vector3.new(0,20,0)))
	robloxianClone.Anchored = false
	robloxianClone.Parent = game.Workspace.SpawnedEggs
end

Also ensure that the models have a primary part for it to work.

1 Like

Alright, thanks, I will check that out.

I’ve tried it out, and they arn’t working. Also now it says “Anchor is not a valid member of workspace.”

I’ve tried to delete both of em, and they spawn but they spawn like a trooper group. They spawn one behind the other in a straight line not random…

If they’re spawning in a straight line, that’s probably because the spawns are also in a line. I don’t see why you’re getting that error, is what you sent the full script?

Yes, and the spawns are spread ed everywhere.

What line is the error on? The clones should be randomly spawning at each spawn.

It just says “Anchored is not a valid member of model.”

Ah, I missed that earlier. Try replacing it with this

for _,c in pairs(robloxianClone) do
	if c:IsA("BasePart") then
		c.Anchored = false
	end
end

Can you input it into my script and give me the full script?

local robloxians = game.ReplicatedStorage.Robloxians

local spawns = game.Workspace["Robloxian Spawns"]

while wait(2) do
	local robloxianTable = robloxians:GetChildren()
	local randomrobloxians = robloxianTable[math.random(1,#robloxianTable)]
	local spawnsTable = spawns:GetChildren()
	local randomSpawn = spawnsTable[Random.new():NextInteger(1,#spawnsTable)]
	
	local robloxianClone = randomrobloxians:Clone()
	robloxianClone:SetPrimaryPartCFrame(CFrame.new(randomSpawn.Position + Vector3.new(0,20,0)))
	for i,v in pairs(robloxianClone:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Anchored = false
		end
	end

	robloxianClone.Parent = game.Workspace.SpawnedEggs
end

This should work for you

Thanks I’ll try it, ty. Thx for help.