I don’t understand what is going on. The first connection disconnects just fine, and I set up the second connection the same way yet it won’t disconnect. It will print “Connection” though.
local connection = nil
local scannedpart = nil
local connect22 = nil
script.Parent.deletebutton.MouseButton1Click:Connect(function()
if canDeleteValue == true then
StopFunctionValue = true
canDeleteValue = false
script.Parent.deletebutton.Image = secondarytexture
SelectionBox()--create the selection box
connection = screenmouse.Move:Connect(function() --when the mouse moves, detect it
Mouse.HitPosition()
if truepart11.Parent.Parent.Name == "ItemStorage" then
if truepart11.Parent.Parent.Parent.Name == Player.Name then
s.Parent = truepart11.Parent
s.Adornee = truepart11.Parent
print(truepart11.Parent.Parent.Name)
scannedpart = truepart11
-----------------
--Deciding on what part to delete
local GuiName = scannedpart.Parent.Name
local item = script.Parent.Parent.StructureFrame.Frame:WaitForChild(GuiName)
local Energycost = item.EnergyCost.Value
local Moneycost = item.MoneyCost.Value
--
connect22 = screenmouse.Button1Up:Connect(function()
print(connect22) --WHERE THE ERROR OCCURS!!!!!!!!
connect22:Disconnect()
end)
end
end
end)
else
connection:Disconnect()
script.Parent.deletebutton.Image = maintexture
--end the delete function
canDeleteValue = true
StopFunctionValue = false
s:Destroy()
end
end)
Help!