Basically I have started to learn OOP and decided to put my learning to the test and create a zombie class along with 2 other classes of zombies that inherit the zombie classes functions. However I’m working on the contructer function and whenever I try to set the spawnpoint of the actual physical zombie I’m getting thrown this error anyone know why?
Did you make sure to return Zombie within your zombie module? Also, line 8 of your runner script is incorrect. Also, to move the zombie model, you will need to move its primary part. In the case of characters, the primary part is generally the HumanoidRootPart. Line 8 should be replaced by NewZombie.Model:SetPrimaryPartCFrame(ZombiePosition) or something equivalent to that.
I’m not sure what “setmetatable()” does, but this could be due to the zombie model returning nil or something.
Perhaps have code safeguards on the Zombie.new() function like this:
You have a module in ReplicatedStorage called “Zombie” in addition to a model with the same name, so it’s referencing the module instead of the model. You would have to change the name of the zombie model or of the zombie module so they’re different from one another.
local ZombieModPath = nil
for _, v in game.ReplicatedStorage:GetChildren() do
if v.Name ~= "Zombie" or not v:IsA("ModuleScript") then
continue
end
ZombieModPath = v
end
local ZombieMod = require(ZombieModPath)