Well, what I'm getting at is that you need a module script or a RemoteEvent. I highly recommend a Remote Event.
Remove Event and Remote Function Tutorial
The difference between a Remote Event and Remote Function is that a Remote Function has a callback so you can return a value.
First up, you need to create a RemoteEvent. You should always put RemoteEvents and RemoteFunctions inside of ReplicatedStorage. I created one and called it 'Event'
Now, from what I'm getting at you want the functions inside of the Client and the functions to be called by the Server. Here's the Client script:
08 | game.ReplicatedStorage.Event.OnClientEvent:connect( function (request, func, ...) |
09 | if request = = "runFunction" then |
10 | if func = = "move" then |
16 | elseif func = = "eat" then |
When you use ... as an argument, it basically creates let's you pass infinite arguments after. If you do args = {...}
that turns all the arguments passed into a table. In your server script:
1 | game.ReplicatedStorage.Event:FireClient( "runFunction" , "move" , 5 , 8 , 10 ) |
or you can do this for eat:
1 | game.ReplicatedStorage.Event:FireClient( "runFunction" , "eat" , "apple" ) |
Hope I helped! If you want to learn about ModuleScripts be sure to check this out:
Module Script Video Tutorial
If I did help out, please let me know :)