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

RemoteFunction outputting weird error?

Okay so I'm trying to use a RemoteFunction to return the number of available slots in my custom inventory thingamadoohickey, but it's outputting some sort of weird error that I can't comprehend. Could someone help me with this?

Error: 09:06:21.275 - OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available

Error line: script:FindFirstChild("GetSlots").OnServerInvoke:connect(function(player, arg)

Client line: local slots = Workspace.CoreGUIReplace.GetSlots:InvokeServer("Sending slots...")

I'd be very grateful if someone were to help me with this, thanks!

1 comment

0

Nevermind, figured out the error

1 answer

To anybody that stumbles across this, the bug is that OnServerInvoke is a user-definable function, not an Event.

What this means is that you use it like so:

RemoteFunction.OnServerInvoke = function(params)
	--code
end

--Or, alternatively:

function RemoteFunction.OnServerInvoke(params)
	--code
end

Instead of like so:

--Remember, this is invalid!

RemoteFunction.OnServerInvoke:connect(function(params)
	--code
end)

--Or, alternatively:

function funcName(params)
	--code
end
RemoteFunction.OnServerInvoke:connect(funcName)

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