Zombie not spawning in defined position

I made a contructer function for a zombie however instead of spawning in it’s defined position which is the position of the zombie spawner it spawns in the position of where the model I’m cloning it from in replicated storage has.

code:

function Zombie.new(position)

	local self = setmetatable({}, Zombie)
	
	self.Model = game.ServerStorage.ZombieModel:Clone()
	self.Model.Name = "Zombie"
	self.Model.Parent = game.Workspace
	self.Model.HumanoidRootPart.CFrame = CFrame.new(7.65, 6.75, 24.55)
	
	self.health = 100
	self.speed = 8
	self.damage = 10
	self.state = "Idle"
	
	print(self.Model)
	
	return self
end

Have you tried using the MoveTo function that models have instead of manually assigning the humanoid a position?

1 Like

is that not used for pathfinding?

You’re not even using position? You’re hardcoding the position

self.Model.HumanoidRootPart.CFrame = CFrame.new(7.65, 6.75, 24.55)

No, this function just moves a model’s PrimaryPart to a specific position. Humanoid:MoveTo is what I think your referring to.

Sorry it was originally position I’ve been changing the code around to see if it will act differently