Zombie only spawning on one place

Code:
local NPC = game.ReplicatedStorage[“Zombie”]
local Spawner = script.Parent

while true do
local Clone = NPC: Clone()
Clone.UpperTorso.CFrame = Spawner.CFrame
Clone.Parent = workspace
wait(5)
end

i put that script in the baseplate but zombies are only spawning were they were before i putted them in the replicated storage. is there a way i can make the code spawn zombies different places and not on the same place?

You can change the clone’s HumanoidRootPart CFrame before parenting it to the workspace.

Clone.HumanoidRootPart.CFrame = CFrame.new(coordX, coordY, coordZ)

That’ll do it. You are able to get fancy and use math.random() using a Vector3 Value to spawn them all over the place.

let me test it and see if it works.

am i doing this write? they are not spawning in.wa

they are falling from the map.

You’re supposed to replace coordX, coordY, and coordZ with your own coordinates.

… ok maybe i will stop and just do it the old fashion way. i am getting tried of asking for help. Time for free model.

They’re not spawning in since I don’t think you should make a space between NPC and Clone
Try removing the space between NPC: Clone()

So the script should look like this:
local NPC = game.ReplicatedStorage.zombie
local Spawner = script.Parent

while true do
local Clone = NPC:Clone()
Clone.HumanoidRootPart.CFrame = CFrame.new(X, Y, Z) – Replace X,Y,Z with your cords
Clone.Parent = game.workspace
wait(5)
end

1 Like

Then you would never improve, the reason why it spawned falling in the map because your Y cord is wrong or rather too high

if you are gonna use free model and give up getting help then you wont be able to learn scripting and you wont improve in it

try this one i will explain you how the Cframe works:

local NPC = game.ReplicatedStorage.zombie
local Spawner = script.Parent

while true do
local Clone = NPC:Clone()
Clone.HumanoidRootPart.CFrame = Spawner.CFrame * CFrame.new(math.random(1,10),(math.random(1,10),(math.random(1,10))
Clone.Parent = game.workspace
wait(5)
end

we used this sign * so that it plus the spawner position which mean it will get a random number between 1 and 10 and the random number is 6. then if the spawner position is 9,0,1 then it will be 15, 6, 7 which mean the Clone will be in that position