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:
local guiPopUpEvent = game.ReplicatedStorage.OpenIslandThingyThingThing local guiClosedEvent = game.ReplicatedStorage.CloseIslandThingyThingThing local islandSwitchGUI = script.Parent local click = islandSwitchGUI.Click guiPopUpEvent.OnClientEvent:Connect(function(plr) if not islandSwitchGUI.Enabled then islandSwitchGUI.Enabled = true click:Play() spawn(islandSwitchGUI.Close.CloseButton.MouseButton1Click:Wait()) spawn(islandSwitchGUI.GO.Button.MouseButton1Click:Wait()) -- Continue program end 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:
local guiPopUpEvent = game.ReplicatedStorage.OpenIslandThingyThingThing local guiClosedEvent = game.ReplicatedStorage.CloseIslandThingyThingThing local islandSwitchGUI = script.Parent local click = islandSwitchGUI.Click guiPopUpEvent.OnClientEvent:Connect(function(plr) if not islandSwitchGUI.Enabled then islandSwitchGUI.Enabled = true click:Play() local closed = false while not closed do islandSwitchGUI.Close.CloseButton.MouseButton1Click:Connect(function() closed = true end) if not closed then islandSwitchGUI.GO.Button.MouseButton1Click:Connect(function() closed = true end) end wait() end -- Continue program end end)
Thanks for trying to help!
Well you should probably learn how to use coroutines.
You can maybe try this:
-- at the start local condition1 = false local condition2 = false islandSwitchGUI.Close.CloseButton.MouseButton1Click:Connect(function() condition1 = true end) islandSwitchGUI.GO.Button.MouseButton1Click:Connect(function() condition2 = true end) -- lines twelve and thirteen, replace with repeat wait() until condition1 or condition2