I searched this question on google, but instead, showed me how to FIRE multiple functions and not WAIT for multiple functions to fire.
My goal is to see if a function fired out of two functions. If both functions fired at the same time somehow, then it will continue the program. If one function fires, but not the other, then it will continue the program. If no functions fire, then keep waiting for one of them to fire.
Here's the code:
01 | local guiPopUpEvent = game.ReplicatedStorage.OpenIslandThingyThingThing |
02 | local guiClosedEvent = game.ReplicatedStorage.CloseIslandThingyThingThing |
03 | local islandSwitchGUI = script.Parent |
04 | local click = islandSwitchGUI.Click |
05 |
06 | guiPopUpEvent.OnClientEvent:Connect( function (plr) |
07 | if not islandSwitchGUI.Enabled then |
08 | islandSwitchGUI.Enabled = true |
09 |
10 | click:Play() |
11 |
12 | spawn(islandSwitchGUI.Close.CloseButton.MouseButton 1 Click:Wait()) |
13 | spawn(islandSwitchGUI.GO.Button.MouseButton 1 Click:Wait()) |
14 |
15 | -- Continue program |
16 | end |
17 | end ) |
I got this error when it ran:
Spawn function requires 1 argument - Client - Show&Hide:12
(Show&Hide is the script name)
I did this:
01 | local guiPopUpEvent = game.ReplicatedStorage.OpenIslandThingyThingThing |
02 | local guiClosedEvent = game.ReplicatedStorage.CloseIslandThingyThingThing |
03 | local islandSwitchGUI = script.Parent |
04 | local click = islandSwitchGUI.Click |
05 |
06 | guiPopUpEvent.OnClientEvent:Connect( function (plr) |
07 | if not islandSwitchGUI.Enabled then |
08 | islandSwitchGUI.Enabled = true |
09 |
10 | click:Play() |
11 |
12 | local closed = false |
13 |
14 | while not closed do |
15 | islandSwitchGUI.Close.CloseButton.MouseButton 1 Click:Connect( function () |
Thanks for trying to help!
Well you should probably learn how to use coroutines.
You can maybe try this:
01 | -- at the start |
02 | local condition 1 = false |
03 | local condition 2 = false |
04 | islandSwitchGUI.Close.CloseButton.MouseButton 1 Click:Connect( function () |
05 | condition 1 = true |
06 | end ) |
07 | islandSwitchGUI.GO.Button.MouseButton 1 Click:Connect( function () |
08 | condition 2 = true |
09 | end ) |
10 |
11 | -- lines twelve and thirteen, replace with |
12 | repeat wait() until condition 1 or condition 2 |