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

RemoteFunction connect failure please help?

Asked by
Voltoxus 248 Moderation Voter
9 years ago

Code: Condensed to fit in website textbox

local a = game.Workspace.RemoteEvents.RequestAuth
a.OnServerInvoke:connect(AuthCode)

RemoteEvents is a Folder Class

RequestAuth is a RemoteFunction Class

AuthCode is a function inside the script

Output:

18:23:39.788 - OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available

18:23:39.788 - Script 'game.Workspace.RemoteEvents.RequestAuth.OnServerInvoke:conn', Line 1

18:23:39.789 - Stack End

Question: I would appreciate any help on solving this, I know how remote events work so I attempted to translate that knowledge to a remote function because I need information to return.

2 answers

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

This is the one of the two things I hate, and I mean hate about RemoteFunctions. Remote functions are a callback (and I don't quite get what that means, I guess they are meant to return a value). Which means they need to be in some special function, seeing as they are not technically a event like RemoteEvents.

To use bindable function, you would want to use the below code.

local a = game.Workspace.RemoteEvents.RequestAuth
function a.OnServerInvoke(Player, AuthCode) --Since it is not a event, it will not need a connection line. Also, since this is likely being fired from the client, there is a variable automatically sent to the server containing the sender's value. So you might want to add that to the callback line.
end

On a personal note, another thing I hate about RemoteFunctions is, you can't do this;

function game:service'ReplicatedStorage'.Test.OnServerInvoke()

or this;

function game.ReplicatedStorage['Test'].OnServerInvoke()
Ad
Log in to vote
0
Answered by
Voltoxus 248 Moderation Voter
9 years ago

Figured it out thanks for trying

Answer this question