Args = event.OnServerEvent:Wait() not returning custom parameters, only default 'player'

Local Script:

local character = "bababooey"


local args = RS.Combat.Events["Character Hit"].OnServerEvent:Wait()
local var_1 = args[1] --should return client's player (iUnEarthly)
local var_2 = args[2] --should return "bababooey"

Instead, all I’m getting is this error on the “var_1” line.

1 is not a valid member of Player "Players.iUnEarthly"

What am I missing? I thought :Wait() was supposed to return the parameters of the called event? Right now it only looks like it’s returning the default “player” param from OnServerEvent.

Is there a way to bypass not being able to return values from Connect:() or a way to return a value from a double nested connect event function? Like a ‘return return x’? Otherwise, I’m stuck with :Wait() and this issue.

There’s GOT to be a way to do this securely. Help, please! It’s also late and I’m burned out, so it’s possible that I’m missing something obvious.


The problem is that OnServerEvent does not return a table, but rather a tuple, essentially a list of variables.
The following should work:

local var_1, var_2 = RS.Combat.Events["Character Hit"].OnServerEvent:Wait()

Adding on to what @xendatro, you can convert it to a table by doing:

local Args = {RS.Combat.Events["Character Hit"].OnServerEvent:Wait()}
1 Like

You’re only assigning one variable, RBXScriptSignal:Wait returns the event arguments as a tuple.
You can use multiple assignment to get the additional parameters.

local Player, Param1, Param2 = <RBXScriptSignal>:Wait()

If you have variable arguments, you can pack them.

local Arguments = table.pack(
local Player = table.remove(Arguments)

Keep in mind that RBXScriptSignal is the RemoteEvent’s OnClientEvent property.


This is the distinction that I completely missed. Thanks :slight_smile: