Cannot diconnect, unknown global

local BookOneCon = script.BOOKS_FOLDER.Value.BOOK_ONE.PROMPT.Triggered:Connect(function()
		script.UPDATE_CLUES:FireAllClients("A", ONE)
		BookOneCon:Disconnect()
end)

BookOneCon:Disconnect(), the function is underlined orange

1 Like

The variable isn’t seem within the scope.

local BookOneCon; BookOneCon = script.BOOKS_FOLDER.Value.BOOK_ONE.PROMPT.Triggered:Connect(function()
	script.UPDATE_CLUES:FireAllClients("A", ONE)
	BookOneCon:Disconnect()
end)

Define the variable first, then use it


Alternatively, you can just use RBXScriptSignal:Once to disconnect the event once it fires

1 Like

If you want to disconnect from inside of the function then you have to declare beforehand.
Like this:

local BookOneCon
BookOneCon = script.BOOKS_FOLDER.Value.BOOK_ONE.PROMPT.Triggered:Connect(function()
		script.UPDATE_CLUES:FireAllClients("A", ONE)
		BookOneCon:Disconnect()
end)

Oh yes i forgot bout that. thanks

1 Like

1 Like

still i have the next problem right here

You defined the variable twice, don’t put local in front of the definition:

image

2 Likes

o- o that well it didnt actually matter i found out

1 Like