I’m working on a knit template game for some reason this code isn’t running
local Knit = require(game:GetService("ReplicatedStorage").Knit)
local Janitor = require(Knit.Util.Janitor)
local MyComponent = {}
MyComponent.__index = MyComponent
MyComponent.RequiredComponents = {}
MyComponent.Tag = "MyComponent"
MyComponent.RenderPriority = Enum.RenderPriority.Camera.Value
MyComponent.RequiredComponents = {"AnotherComponent", "YetAnotherComponent"}
function MyComponent.new(instance)
local self = setmetatable({}, MyComponent)
self._janitor = Janitor.new()
return self
end
function MyComponent:Init()
print("Initialized. Bound to: ", self.Instance:GetFullName())
end
function MyComponent:Deinit()
print("About to clean up")
end
function MyComponent:HeartbeatUpdate(dt)
print("Heartbeat", dt)
end
function MyComponent:SteppedUpdate(dt)
print("Stepped", dt)
end
function MyComponent:RenderUpdate(dt)
print("Render", dt)
end
function MyComponent:Destroy()
self._janitor:Destroy()
end
return MyComponent
But this runs(edited)
local DanceFloor = {}
DanceFloor.__index = DanceFloor
-- The CollectionService tag to bind:
DanceFloor.Tag = "DanceFloor"
-- [Optional] The RenderPriority to be used when using the RenderUpdate lifecycle method:
DanceFloor.RenderPriority = Enum.RenderPriority.Camera.Value
-- [Optional] The other components that must exist on a given instance before this one can exist:
DanceFloor.RequiredComponents = {}
-- How often the color changes:
local UPDATE_INTERVAL = 0.5
function DanceFloor.new()
local self = setmetatable({}, DanceFloor)
self._nextUpdate = time() + UPDATE_INTERVAL
return self
end
function DanceFloor:HeartbeatUpdate(dt)
if (time() > self._nextUpdate) then
-- Set the assigned instance to a random color:
self.Instance.Color = Color3.new(
math.random(),
math.random(),
math.random()
)
self._nextUpdate = self._nextUpdate + UPDATE_INTERVAL
end
end
function DanceFloor:SteppedUpdate(dt)
print("Stepped", dt)
end
function DanceFloor:Destroy()
end
return DanceFloor