How to get data from :wait() event

So I made an event on a script to interact with another script

game.ReplicatedStorage.EndGame:Fire("TimeEnded")

And I wait for this function in the other script

game.ReplicatedStorage.EndGame.Event:Wait()

But as you can see in the first script I want to send data to the other script, I can acces the data if I use function instead of wait but I want to use this wait function, then how can I acces the data?

because you can’t acces the data between () of the wait because obviously here only needs time…

Simply save the return of the Wait() call to a variable

local var = game.ReplicatedStorage.EndGame.Event:Wait()
print(var) -- TimeEnded
9 Likes

Add on: given that arguments passed to BindableEvent.Fire are like a tuple, you can also marshal the fired arguments into a table, if you’re catching an arbitrary amount of arguments.

local stuff = {EndGame.Event:Wait()}

I haven’t tried with table.pack but I’d assume it’s the same concept.

3 Likes