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

RemoteFunction outputting weird error? [closed]

Asked by 10 years ago

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!

0
Nevermind, figured out the error 1GREENBOB123456 15 — 10y

Locked by adark, Redbullusa, Thewsomeguy, and TheGuyWithAShortName

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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)
Ad