Knit: "Could not find service" issue

Not too sure, I scraped the API and I can’t figure out what I’m doing wrong.

I’m creating a service on the server, creating a controller on the client, I’m initializing Knit on both, adding the services & controllers using .AddServices and .AddControllers. I’m warning on the client and the server to give me a clear indication of when the services have initialized and started through usage of :KnitInit and :KnitStart, yet no matter what I do I’m given the following error:

ReplicatedStorage.Knit.KnitClient:126: Could not find service “MainService”

I’ll leave the code here in the important snippets as the rest of the code is unrelated to Knit and wouldn’t affect the issue.

–Client

Knit = require(ReplicatedStorage.Knit)
RemoteSignal = require(Knit.Util.Remote.RemoteSignal)

MainController = Knit.CreateController { Name = "MainController" }




function MainController:KnitInit()
	warn("Main Controller Initialized")
end

function MainController:KnitStart() 

	warn("Main Controller Starting")

	local MainService = Knit.GetService("MainService")
	MainService.OnBlockUpdate:Fire()

end -- end of KnitStart


return MainController

SERVER:

ReplicatedStorage = game:GetService("ReplicatedStorage")

Knit = require(ReplicatedStorage.Knit)
RemoteSignal = require(Knit.Util.Remote.RemoteSignal)

local MainService = Knit.CreateService { Name = "MainService", Client = {} }


function MainService:KnitInit()
	warn("Main Service initialized")
	self.Client.OnBlockUpdate = RemoteSignal.new()
	
	self.Client.OnBlockUpdate:Connect(function(Player)
		print("Invoked")
	end)
end


function MainService:KnitStart()
	warn("Main Service started")
end



return MainService
2 Likes

Can you show me your runtime bootstrappers please? Both the client and server counterparts. :slight_smile:

2 Likes

Hi, so I ended up solving the issue, I was defining the RemoteSignal inside of Knit Init when it should’ve been placed directly into the client table inside MainService.

I’m not sure why, but it doesn’t actually create a folder inside the Knit Module for Services that don’t have remote properties, remote signals, etc. defined in them, I guess it’s because realistically they wouldn’t have any communication with the client unless you tried to do it my way.

2 Likes

That makes sense! Happy Knitting. :laughing:

2 Likes

Had the same issue very recently, Thanks a bunch!!

1 Like