I need help with my Code

I was trying to make a zombie summoner for my zombie fighting game but it doesn’t work, it only summoned one zombie. I didn’t find any solution to it whatsoever. If there is a way to fix please reply down bellow.

Code:

local Minions = game.ReplicatedStorage.Minions:Clone()
local Pos = script.Parent.Position + Vector3.new(0,3,0)

while true do
	wait(10)
	Minions.Parent = game.Workspace
	Minions.Position = Pos
end
2 Likes

You are not cloning the minions inside of the loop.
You should do this:

local Pos = script.Parent.Position + Vector3.new(0,3,0)

while true do
	wait(10)
    local Minions = game.ReplicatedStorage.Minions:Clone()
	Minions.Parent = game.Workspace
	Minions.Position = Pos
end
4 Likes

You are parenting the same Minions object to workspace over and over, you should be parenting a clone of it to workspace over and over.

while true do
	wait(10)
    local NewMinion = Minions:Clone()
	NewMinion.Parent = game.Workspace
	NewMinion.Position = Pos
end

Also

local Pos = script.Parent.Position + Vector3.new(0,3,0)

You should be setting Pos inside of the loop if you want it to stay updated. Otherwise Pos will never update to script.Parent’s new position.

1 Like

I tried your idea and it still did not work. :slightly_frowning_face:

Were there any errors? And what do you mean by didn’t work, did only one minion spawn or did none spawn?

1 Like

What is Minions in replicated storage?

What you’re doing is making 1 Minion, parenting the minion to workspace and then doing it every 10 seconds and saving the “Pos” as a permanent Vector3, not above the Summoner.
I suggest changing it to:

local Summoner = script.Parent.Parent -- fix this path 

while Summoner and Summoner:FindFirstchild("Humanoid") and wait(10) do
	local Minion = game.ReplicatedStorage.Minions:Clone()
	Minion.Parent = game.Workspace
	Minion.CFrame = Script.Parent.CFrame + Vector3.new(0,3,0)
end
1 Like

If minions is a model and not a part, it does not have a position property and the line where you set its position will error. You can try this instead:

NewMinion:SetPrimaryPartCFrame(CFrame.new(Pos))

Instead of

NewMinion.Position = Pos
1 Like

I suggest using HumanoidRootPart.CFrame instead of
NewMinion:SetPrimaryPartCFrame as the Motor6Ds, etc will get destroyed.

1 Like

My studio was having problems with the toolbar before so maybe it’s that?

Nope, That has nothing to do with scripts

It still did not work it only summoned one time.

while true do
	wait(10)
    local NewMinion = Minions:Clone()
	NewMinion.Parent = game.Workspace
	NewMinion.Position = Pos
repeat
end
1 Like

The error said SetPrimaryPartCFrame is not a valid member of Folder

It said SetPrimaryPartCFrame is not a valid member of Folder what does it mean?

could u show explorer of minion

  1. Can you show us the layout of the Summoner and the Minion? Like their children and path in explorer.
  2. Try using:
local Minion game.ReplicatedStorage.Minions
local Summoner = script.Parent.Parent -- fix this path

repeat
    local NewMinion = Minion:Clone()
    NewMinion.Parent = workspace
    NewMinion.HumanoidRootPart.CFrame = Summoner.HumanoidRootPart.CFrame + Vector3.new(0,3,0)
    wait(10)
until not Summer or not Summoner:FindFirstchild("Humanoid") or Summoner.Humanoid.Health == 0
1 Like