:Wait() RemoteEvent only returns one argument

I am making a build system for one of my experiences. I am trying to use the :Wait() function to detect when a RemoteEvent fires from client to server ONCE, which also passes along build part information. However, it only ends up returning a single argument on the server… is there a workaround to this or is this a bug?

Server:

local data = buildGui.BuildEvent:Wait()
print (data)

Client:

buildGui.BuildEvent:FireServer(in here is the rest of the data)

buildGui is a GUI inside of PlayerGui.

It ends up outputting just the player, and ignoring the rest of the data.

If you know how many variables are being passed through you can do something like

local sender, value1, value2, etc = buildGui.BuildEvent:Wait()
print(sender)
print(value1)

Or you could pack them into a table

local data = table.pack(buildGui.BuildEvent:Wait())
for i, v in ipairs(data) do
print(v)
end
1 Like

I think that part is misspelled

local data = buildGui.BuildEvent.OnServerEvent:Wait()

and data will always be the player, since that is the first argument, you can do this or use the answer above

local data =  {game.ReplicatedStorage.RemoteEvent.OnServerEvent:Wait()}
data = data[2]
1 Like

When you call :Wait(), it returns the arguments as a tuple (multiple values). A variable can only hold one value, so when you do:

local data = buildGui.BuildEvent.OnServerEvent:Wait()

it only stores the first argument (the player who fired the remote) in the data variable and discards the rest.

You can try either solution mentioned above to fix this. Although I’m curious as to why you only want to listen for the event using :Wait() instead of a regular connection though, I don’t see any use case for that in a build system.

1 Like

The reason I’m using Wait() is because the build system for this game is not a sandbox building system (like Minecraft). To build, you click on a pre-determined build location (almost like a tower defense game, although my game is not one), which opens a GUI with all of the possible parts. When you select a part to build, the event fires and the part gets built.