local clientScriptSpeedAbilitiesModule=loadMouleFunction:InvokeServer(assetIdModule)
--warn(clientScriptSpeedAbilitiesModule)--Debug
if not clientScriptSpeedAbilitiesModule then return end
loadModuleFunction.OnServerInvoke=function(player:Player,assetId:number)
local success,module=pcall(function()
return require(assetId)
end);if not success then return nil end
return module
end
I call the client module from the client by AssetId on the server and then return the values ​​to the client. For some reason, an error appears: attempt to call a nil value when joining the game and subsequent clicks on the button.
My best guess is that whatever MainModule you require()'d didn’t have the functions you were trying to use. Make sure to check what index of the given module caused the error.
Also, unless you plan to make a Script Builder game, you should NEVER let the client tell the server what module ID to require or what code to execute, as that could easily be abused by exploiters to ruin your game.
In the case this isn’t a Script Builder game, you should instead have this required module be integrated with your game by parenting it to ReplicatedStorage, as it can be indexed by both the client and the server, with the server capable of automatically replicating changes to the service and its descendants to clients.
Well, I don’t know how to help you if you can’t/don’t want to post it here, considering this is an error due to calling a function that doesn’t exist in the module. Are you sure the function is exactly named “inputBegan” and was defined with a period rather than a colon?
UIS.InputBegan:Connect(function(input,gameProcessedEvent)
warn(clientScriptSpeedAbilitiesModule.inputBegan)--output nil
clientScriptSpeedAbilitiesModule.inputBegan(input,gameProcessedEvent,character,initialSizeX,speedLineFrame)--this line causes an error
Module:
function module.inputBegan(input,gameProcessed,character,initialSizeX,speedLineFrame)
I call it by assetId, the location of the module is not important here. If I understand correctly, the location is not taken into account when publishing a module.
I call the module from the server, from ReplicatedStorage, technically the module is located where it is called, the result is the same.
No, I’m asking why you’re going through the hassle of publishing the module and getting its asset id when you can leave It in the game. Are you doing this for security reasons?
It explicitly says you cannot pass functions… Why don’t you fire the arguments to the server that will be passed to your module? I’m not really sure if your module is entirely client based though
Btw quick tip, you cannot pass the input object from the client from the server btw so you’ll have to rework some things. If your module just checks for keycodes then just pass the keycode instead of the input object