require(assetId) cannot be called from a client

So I was working on this script where when you touched this block it will pop up with a GUI that will have text But when I added these two buttons where it asks you, yes or no I got this error
require(assetId) cannot be called from a client.
and I change the scripts in the yes and no buttons but all of them say the same error?
by the way, when I put the text on the player’s screen I put it in playerGUI

Client-sided requiring of AssetIds of ModuleScripts isn’t possible because that is a security issue (malicious modules can be loaded in by a client)

You can mitigate this by using a RemoteFunction, have your LocalScript InvokeServer(the assetId), have another ServerScript listen to the RF, require it with that script, and return the contents of the module back to the LocalScript, although that is still a security issue.

1 Like

What is InvokeServer and what id would I put in the brackets?

1 Like

InvokeServer is a function of a RemoteFunction, only visible with a LocalScript, and can be used to send and receive data to and from the server.

You will send the ID to the InvokeServer() method, again usable only in LocalScripts.

RemoteFunction:InvokeServer(12345678) -- example ModuleScript assetId

Here’s some links to get you started with RemoteFunctions:

I won’t be able to help you any further until some time after 12 PM PHT, I’ll be taking some rest.

1 Like