Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can't I call method InvokeServer on remote functions? [SOLVED]

Asked by 4 years ago
Edited 4 years ago

The server side:


local remoteWalk = Instance.new("RemoteFunction") local remoteRun = Instance.new("RemoteFunction") local function Walk(client) stats.human.WalkSpeed = 16 --stats.human refers to a player's humanoid end local function Run(client) stats.human.WalkSpeed = 32 end remoteWalk.OnServerInvoke = Walk remoteRun.OnServerInvoke = Run

The following code is in a module script, which is required by a local script.


local requests = ActionManager.ActionRequests --A table containing the remote functions local remoteWalk = requests["Walk"] --the "Walk" remote function from the server script local remoteRun = requests["Run"] --the "Run" remote function from the server script local function Walk() remoteWalk:InvokeServer() end local function Run() remoteRun:InvokeServer() end --The "Walk" and "Run" functions are bound to keyboard inputs

I've simplified the code a bit to make it more readable. When the remote functions are invoked by the client, I get this error:

"Trying to call method on object type: 'RemoteFunction' with incorrect arguments."

I thought that was because I previously hadn't included a "client" argument on the server side, but I still get the same error. Could it be because the code is required from a module script? It's definitely being performed on the client. Thanks for the help!

1 answer

Log in to vote
0
Answered by 4 years ago

I figured it out, I was setting the OnServerInvoke property of 'remoteRun' to 'remoteRun' instead of the run function by mistake. The code above should work properly lol

Ad

Answer this question