Where to get the component instance from knit?

Hey all, I have recently started to use the knit framework in Roblox studio and have been finding it relatively useful (still practicing).

However as I am following the game tutorial on how to use knit, I am confused on how to get the instance of a component. I’ve looked on the documentation in order to find out how but I’m still confused.

Bare in mid that I do know that the tutorial is kind of outdated, I am trying to use more recent methods.

local Knit = require(game.ReplicatedStorage.Packages.Knit)
local Component = require(Knit.Util.Component)
local Trove = require(Knit.Util.Trove)

local Goal = Component.new({ Tag = "Goal" })

--// Where would I get the goal instance?
function Goal:Construct()
	self._trove = Trove.new()
	print("Goal was created")
	
	self._trove:Add(function()
		print("Goal Destroyed.")
	end)
end
function Goal:Start() end
function Goal:Stop()
	self._trove:Destroy()
end

return Goal

1 Like

The instance bound to the component is automatically set as Instance property of the component. So doing self.Instance from anywhere inside the component shall return the instance.

Ah, thank you so much. I have been searching for ages.

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