Client Functions not Loading

Hello!

I don’t know exactly what I did wrong, but for some reason none of my functions from a table inside of the server called (Client) is loading.

Here are some screenshots Explaining what I just meant.
image

image

If there is any way to fix this, please tell me.

P.S
it still does not work even without repeat just so you know

The problem you are facing is that calling CFramework:New executes all the code in CFramework:New before defining the :SayHello function. If you want the CFramework to pick up that new function, you have to define it on RandomService before telling CFramework:New to deal with it.

You should either:

  1. Build RandomService before calling CFramework:New:
local CFramework = require(--[[framework here]])

local RandomService = {
    Client = {}
}

function RandomService.Client:SayHello()
    print("hello")
end

CFramework:New(RandomService, "Service", "RandomService")

return RandomService

If this is the case, you may want to rename CFramework:New to something like CFramework:Initialize.

or,

  1. Divide CFramework:New into two functions, one for registering the service, and the other for calling the client methods (or whatever):
-- in CFramework,
function CFramework:New(Table, __type, Name)
    -- register the service here
end

-- or CFramework:Init
function CFramework:Initialize()
    -- call the service's client methods here
    -- or whatever
end
-- in RandomService,

local CFramework = require(...)

local RandomService = CFramework:New(...)

function RandomService.Client:SayHello()
    print("hello")
end

RandomService:Initialize()

return RandomService

I hope that helps!

1 Like