I am making an elevator with a door, and the door has two door panels. canOpen activates the first panel, and canOpen2 activates the second panel. However, when the script is ran, the first panel opens, then the second panel doesn't open until the script has finished running the canOpen script. The script shown below is inside of a bindablefunction. I wonder if there is a way around this. Thanks :)
--ONLY CHANGE IF YOU REALLY KNOW WHAT YOU'RE DOING-- local debounce = false local canOpen=true local canOpen2=true function script.Parent.OnInvoke() canOpen=script.Parent.Parent.Parent.Parent.Door.DoorOpener:Invoke() canOpen2=script.Parent.Parent.Parent.Parent.Door.DoorOpener2:Invoke() end
You have to wrap one of invokes in a spawn function. It delays the opening of the panel because the first invoke yields the script (waits for it to finish). ``` function script.Parent.OnInvoke() spawn(function() canOpen=script.Parent.Parent.Parent.Parent.Door.DoorOpener:Invoke() end)
canOpen2=script.Parent.Parent.Parent.Parent.Door.DoorOpener2:Invoke() end ```