CFrame issues in tower defense game

hi :slight_smile: today i decided to start making a tower defense game.
i am following this tutorial by gnomecode:https://www.youtube.com/watch?v=R3AREWh14iQ&list=PLtMUa6NlF10fEF1WOeDtuGcIn0RdUNL7c

rn, at the part where i set the cframe of a copied zombie from server storage, only 1/2 zombies spawns in, the other is in workspace but just doesnt show up ANYWHERE

heres my script:

local ServerStorage = game:GetService("ServerStorage")
local mob = {}

function mob.Move(mob, map)
	local humanoid = mob:WaitForChild("Humanoid")
	local waypoints = workspace.Waypoints

	for waypoint=1, #waypoints:GetChildren() do
		humanoid:MoveTo(waypoints[waypoint].Position)
		humanoid.MoveToFinished:Wait()
	end
	
end

function mob.Spawn(name, map)
	local mobExists = ServerStorage.Mobs:FindFirstChild(name)
	
	if mobExists  then
		local newMob = mobExists:Clone()
		newMob.HumanoidRootPart.CFrame = workspace.Map.SpawnBlock.CFrame
		newMob.Parent = workspace
		
		coroutine.wrap(mob.Move)(newMob, map)
	else
		warn("Mob could not be found!", name)
	end
end

return mob

and

local mob = require(script.Mob)
local map = workspace.Map

for i=1, 2 do
	mob.Spawn("Zombie", map)
	wait(3)
end

thanks for any help :slight_smile:

1 Like

Put print statements in to provide information.
Inside your 1,2 loop put print("zombie ", i)

Inside your mob.Spawn function after your local mobExists line put
print(name)

Does your warn line print?

1 Like

2 zombies gets printed, i assume it is a problem with the cframe line, as both zombies spawn in the workspace, but 1 just isnt spawning

Anchor the zombie’s RootPart before spawning and check it’s position by selecting it. Stop the mob.Move function as well.
If the zombie just fell off the baseplate then try multiplying the CFrame by some studs up
Or try to use PivotTo on the zombie model
newMob:PivotTo(workspace.Map.SpawnBlock.CFrame)