Self not working

Why is self.Attacking nil?

local module = {}
module.__index = module

function module.Setup()
    
    local Status = {
        Attacking = false
    }
    
    setmetatable(Status, module)
    
    return Status
    
end

function module:M1()
    
    print(self.Attacking)
    
end

return module

i had that same problem and im yet to figure it out

This code works properly. Are you doing

module:M1()

instead of

local new = module.Setup()
new:M1()

?

return the part where you set the metatable i think because that’s how I do module stuff

local module = {}
module.__index = module

function module.Setup()

	local Status = {
		Attacking = false
	}

	return setmetatable(Status, module)

end

function module:M1()

	print(self.Attacking)

end

return module

That changes nothing unfortunately

maybe you are using the module incorrectly

Screenshot 2022-12-04 194515

I was just like @TenBlocke said i had it setup wrong

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