OOP module erroring: CFrame is not a valid member of Model "Normal"

Hey, I’m trying to make a zombie game using OOP.

For some reason it keeps saying that CFrame is not a “valid member” of “Normal”

I’m new to OOP so I’m not sure if I’m missing something, but I couldn’t find something related to my issue.

Here’s the module that’s erroring (In the MT:Spawn function):

local zombie = {}
local MT = {}
MT.__index = MT

function zombie.new(char, name, hp, speed, defense)
	
	--Verifying
	if typeof(char) ~= "Instance" or char:FindFirstChildWhichIsA("Humanoid") == false then return end
	if typeof(name) ~= "string" then return end
	if typeof(hp) ~= "number" then return end
	if typeof(speed) ~= "number" then return end
	if typeof(defense) ~= "number" then return end
	
	--Set metatable
	local self = {}
	setmetatable(self, MT)
	
	self.Char = char:Clone()
	self.Name = name
	self.HP = hp
	self.Speed = speed
	self.Defense = defense
	
	self.__objectType = "Zombie"
	
	return self
	
end

function MT:ApplyProperties()
	
	local char = self.Char
	local humanoid = char:FindFirstChildWhichIsA("Humanoid")
	
	char.Name = self.Name
	humanoid.MaxHealth = self.HP
	humanoid.WalkSpeed = self.Speed
	
end

function MT:Spawn(CFramePosition)
	if typeof(self) ~= "table" or self.__objectType ~= "Zombie" then error("Invalid datatype/object_type") return end
	if typeof(CFramePosition) ~= "CFrame" then error("Invalid datatype (Not CFrame)") return end
	
	local currentZombies = game.Workspace:WaitForChild("currentZombies")
	
	self.Char.CFrame = CFramePosition
	self.Char.Parent = currentZombies
	
end


return zombie

Thanks

Replace this line:

self.Char.CFrame = CFramePosition

With this one:

self.Char:PivotTo(CFramePosition)
1 Like

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