Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.