How to get rid of these warnings in strict mode?

So I just started Object Oriented Programming but I run to this annoying problem. I keep getting warnings saying that setmetatable should take a table and that animationTracks cannot be added to a table.

local Creature = require(script.Parent)

local Enemy = {}
Enemy.__index = Enemy
setmetatable(Enemy, Creature)

function Model)
	local newEnemy =
	setmetatable(newEnemy, Enemy)
	newEnemy.animationTracks = {}

	return newEnemy

return Enemy
I get the following warnings


setmetatable should take a table

cannot add property "animationTrack" to table

How can I get rid of them? Any workaround or other solution that would work?

Shot in the dark but it might be because you don’t have a type for creature? It should go away once you assert that it’s a table.

This doesn’t give me any typecheck errors:


type Creature = {
	animator: Animator;
	config: Configuration;
	model: Model;
	root: BasePart

local creature = :: Creature

setmetatable(creature, {})
1 Like

Thanks, it works. What about this one, it’s really confusing and makes no sense to me.


local Movement = {}
Movement.__index = Movement

function Model, path: Folder)
	local newMovement = {}
	setmetatable(newMovement, Movement)
    -- ...
    return newMovement

function Movement:Start()
    -- ...

return Movement
local movement =, path)

This does not only happen to Start(), it happens to all functions really.

I see.

You can try using assertion to assert that movement is of proper type.

type movement = {
    alignPosition: AlignPosition;
    lastSpeed: number;
    -- etc

local movement =, path) :: movement -- use 2 colons to assert that it's of proper type
1 Like

Now the last question, I get this really awful warning.


and it only pops up as soon as I add child.Value even with :: number it will not go away.

task.delay(child.Value :: number, function()



I think it has to do with your assertion.

Assert that child is a Number/IntValue and you should be able to remove the child.Value :: number assertion.


It makes no difference.

It works with number but not my child.Value


Are you asserting child is an intValue? You could also make another variable which is kinda redundant but it should work.

local number = child.Value :: number
task.delay(number, function() --...

It worked only after I made two variables and asserted them.

local freezeInfo = child :: NumberValue
local freezeTime = freezeInfo.Value :: number
task.delay(freezeTime, function()

1 Like