Metatable is nil

Hello developers,I am trying to make a server-client communication module and I encountered this weird error. Returned value’s metatable is nil.

There’s 0 issue with the remote creations.

Module Code (Client Side):

local Signal do

	Signal = {}
	Signal.__index = Signal
	
	function Signal:Fire(...)

		self.__signal:FireServer(...)

	end

	function Signal:Connect(handler)

		assert(typeof(handler) == "function", OutputFormat:format("Argument #1 must be a function"))

		self.__signal.OnClientEvent:Connect(handler)

	end

end

	function KoolClient:GetService(name: string)

		assert(typeof(name) == "string", OutputFormat:format("Argument #1 must be a string"))

		local res = ServiceRetriever:InvokeServer(name)

		if serverStarted.Value then

			local endpointsfolder = script.Parent:FindFirstChild("EndpointsFolder", true).Value

			if res then

				local folder = endpointsfolder:WaitForChild(name)

				local service = {}

				for i, v in pairs(folder:GetChildren()) do

					if v:IsA("RemoteFunction") then

						service[v.Name] = function(...)

							return v:InvokeServer(...)

						end
						
						RunService.Heartbeat:Wait()

					end

					if v:IsA("RemoteEvent") then
						
						service[v.Name] = setmetatable({__signal = v}, Signal)
						
						RunService.Heartbeat:Wait()
						
					end

					for i, v in pairs(res) do

						service[i] = v
						
						RunService.Heartbeat:Wait()
						
					end
					
					RunService.Heartbeat:Wait()

					return service

				end

			else

				warn(OutputFormat:format(name.." does not exist"))

			end

		else

			warn(OutputFormat:format("All Services aren't available until Kool has started"))

		end

	end

Client Code:

print((getmetatable(Kool:GetService("DataService").E)) --prints nil

Sorry for my bad English. Any help is appreciated

Are you sure that Kool:GetService("DataService").E is not nil? Because getmetatable(nil) returns nil.

It is not nil. Sorry for late reply.

What is the expected metatable supposed to be? Is it the metatable for your signal class, or is it supposed to attached to res? Metatables do not cross the client-server boundary, so if the metatable is being assigned on the server, the client will not have access to it.

The metatable is for the Signal class, res has nothing to deal with it. The metatable is attached on client side.