I have this anonymous function that I have put inside a variable to disconnect it
local triggered
triggered = command.Triggered:Connect(function(triggeringPlayer, flight)
if not player.PlayerGui:FindFirstChild("NewFlight") then
if flight:match("%d+") then
local match = flight:match("%d+")
print(flight:match("%d+"))
for value, index in pairs(screen) do
if index:IsA("Frame") and index.Vol.Text:match(tostring(match)) then
print(index.Vol.Text:match(tostring(match)))
else
local wrongFlightGui = Storage.Gui.WrongFlight:Clone()
wrongFlightGui.Parent = player.PlayerGui
print("Started")
wait(1.5)
wrongFlightGui:Destroy()
triggered:Disconnect()
end
end
end
OpenGUI()
if #player.PlayerGui.NewFlight:GetDescendants() == #Storage.Gui.NewFlight:GetDescendants() then
local Gui = player.PlayerGui.NewFlight.Page
local textBoxes = Gui.TextBox
local previous = nil
if flight:match("%d+") then
previous = flight:match("%d+")
print(flight:match("%d+"))
end
Gui.Creer.Activated:Once(function()
local destination = textBoxes.Destination.Text
local heure = textBoxes.Heure.Text
local vol = "TX "..textBoxes.Vol.Text
local porte = textBoxes.Porte.Text
local statut = Gui.Statut.Text
local couleur = Gui.Statut.TextColor3
spawnLineEvent:FireServer(heure, destination, vol, porte, statut, couleur, previous)
local line = workspace.Ecrans.Ecran.SurfaceGui.Ecran
line.ChildAdded:Once(function(line)
if #line:GetChildren() == 6 then
if line.Destination.Text == destination and line.Heure.Text == heure and line.Porte.Text == porte and line.Statut.Text == statut and line.Vol.Text == vol then
Gui.Message.Text = "La ligne a été créée."
Gui.Message.BackgroundColor3 = Color3.fromRGB(53, 255, 30)
Gui.Message.Visible = true
wait(1.5)
Gui.Parent:Destroy()
else
Gui.Message.Text = "Il y a eu une erreur dans la création de la ligne !"
Gui.Message.BackgroundColor3 = Color3.fromRGB(255, 0, 4)
Gui.Message.Visible = true
wait(1.5)
Gui.Parent:Destroy()
end
end
end)
end)
end
end
end)
But in the :Disconnect()
function, this message is there :
I tried many things, but I’ve came to a conclusion that when I use command:Triggered
, I can’t disconnect it even with a variable, is it a bug or do somebody how to resolve the bug without creating a full function, or just stopping the function where the :Disconnect()
is ?
Thanks for any help