I know about return
method but this time its not need.
Scenario:
-
local function 1
is running now, at a certain timelocal function 2
is running to stop a running thread oflocal function 1
. is this possible?
Implemented:
- As I implement the scenario, I got a different expected scenario which is the
local function 1
still running its thread even thoughlocal function 2
disconnect it viaBindableEvent
.
Reason of making:
- So, I’m making an
Intro UI
to make a scene before it reaches theMain UI
which are the buttons for (Ex. Play, Settings, Load, Etc.). Now, if a player wants to skip the intro, there’s a popup ofSkip UI
that guide them to use theKeyCode
. - (If a Player push that
KeyCode
),local function 2
shouldDisconnect
thelocal function 1
from aBindableEvent
assigned variable.
Example Code:
local TweenService = game:GetService("TweenService")
local BindableEvent = --Instance of BindableEvent
local function FOO()
local IntroFrame = --Instance
local Button = IntroFrame.Button
local Animation = TweenService:Create(Button, TweenInfo.new(5), {Position = UDim2.new(--[[Some values]])})
Animation:Play()
Animation.Completed:Wait()
end
local Connection = BindableEvent.Event:Connect(FOO)
local function BAR()
Connection:Disconnect() -- (O_o)
end
As you can see… BAR()
should Disconnect FOO()
BUT FOO()
's thread is still running in the background. I want it to stop on that spot when BAR()
disconnects it.