Key 'Disconnect' not found in class 'RBXScriptSignal'

I’m currently trying to learn type annotations, and I’ve been following this tutorial by MaximumADHD.

Well trying to apply type annotations to my UI Library, I’ve ran into this issue:
trhisis

Which is weird, because :Disconnect() is a “key” for RBXScriptSignals (atleast to my knowledge).

Here’s my full script:

--!strict

-- Types
type button = {
	front: Frame | CanvasGroup,
	backdrop: Frame | CanvasGroup,
	trigger: TextButton | ImageButton,
	animatingTasks: {
		[number]: RBXScriptSignal -- Idk if this is the best way to make sure it's an array
	},
	state: boolean,
}


-- Variables
local Library = {}

Library.cachedButtons = {} :: {
	[button]: button
}

--[[
	Animates the <strong>button</strong>
	<strong>button:</strong> A button class
]]
function Library.animate(button: button)
	
end

--[[
	Sets the state of all the buttons that are a descendant of <strong>object</strong>
	<strong>object:</strong> The instance to search through for nested buttons
	<strong>state:</strong> The state of which the button should be set to
]]
function Library.setStateOfButtonsNestedIn(object: Instance, state: boolean) -- I kind of need a better name for this function...
	for index, button in Library.cachedButtons do
		if button.trigger:IsDescendantOf(object) then
			if button.state == state then
			else
				if state == true then
					button.state = true
					
				else
					button.state = false
					for index, connection in button.animatingTasks do
						connection:Disconnect() -- This is whats being highlighted
					end
				end
			end
		end
	end
end

return Library

Hopefully my code isn’t too messy to read, if it is, please tell me how I can clean it up (It may be super clean and I’m just subconscious cause a year ago someone said my code sucked)

:Disconnect() is this black magic that only seems to work if you specifically do “connection = x:Connect()” in the same script beforehand

Never mind, I found my solution; I mixed up RBXScriptSignal and RBXScriptConnection. I don’t know how I didn’t catch this :sob:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.