Humanoid is not a valid member of ModuleScript "Zombie"

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?

heres’s my code:
Module Script:
Screenshot 2024-07-02 174030
Script that’s Supposed to spawn zombie in:

1 Like

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.

1 Like

I made all the changes you suggested and got this erro now

SetPrimaryPartCFrame is not a valid member of ModuleScript “Zombie”

Something interesting is when I print out what the model is I get Zombie and not something like ZombieModel

1 Like

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:

if not model or not model.Parent then
    return
end

That’s all I could think sadly. Hope this helps.

1 Like

Do you know what OOP Stands for?

1 Like

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.

1 Like

image

Model:SetPrimaryPartCFrame() is deprecated. Use Model:PivotTo(CFrame).

Sets a metatable to another table. If you have no idea what is a metatable, read here.

1 Like

Check if the ZombieMod is a Module

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)
1 Like

I cant believe that was the problem istg I always make stupid mistakes

2 Likes

I wasn’t sure what it meant sorry.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.