Hello i’m trying to add an custom object called PlayerManager to another object called Server using trove, however its giving me a type error whenever I try to add it. PlayerManager has a Destroy function so this should not occur. Is anybody else having this issue?
function Server:_init()
local PlayerManager = require(script.Components.PlayerManager) -- lazy loading
self.PlayerManager = self._trove:Add(PlayerManager.new(self))
end
Honestly I don’t think you should even have to deal with this
Just edit the source to make it accept any or straight up cast PlayerManager to any while passing it in trove
--!strict
local Trove = require(script.Parent.Trove)
local Engine = require(script.Engine)
type CarContainer = {
_trove: Trove.Trove,
Engine: any,
}
type CarMethods = {
__index: CarMethods,
new: () -> Car
}
type Car = typeof(setmetatable({} :: CarContainer,{} :: CarMethods))
local Car = {} :: CarMethods
Car.__index = Car
function Car.new()
local self = {} :: CarContainer
self._trove = Trove.new()
self.Engine = self._trove:Add(Engine.new()) -- type error
return setmetatable(self,Car)
end
return Car
Engine Module:
--!strict
local Trove = require(script.Parent.Parent.Trove)
type EngineContainer = {
_trove: Trove.Trove
}
type EngineMethods = {
__index: EngineMethods,
new: () -> Engine
}
type Engine = typeof(setmetatable({} :: EngineContainer,{} :: EngineMethods))
local Engine = {} :: EngineMethods
Engine.__index = Engine
function Engine.new()
local self = {} :: EngineContainer
self._trove = Trove.new()
return setmetatable(self,Engine)
end
return Engine