How can i disconnect a function?

Hello everyone,
I’m trying to change the color of the name of each item in my custom inventory.
I use a local script in my text label and i disable it and then set the rarity color but if it is the “Secret” Rarity, i put disabled = false.

It is very strange because the colors are set for the backpacks but not for the tools…
I think the problem come from the function, and I think I need to disconnect the function.

What I tried is setting “av” to my variable, turn it to false and then I tried this :

local av; -- Set to nil
if av then av:Disconnect() end
av = function SetupIFrame()

But it doesn’t work because it seems impossible to link av and the function.

Does anyone has an idea?
If you have questions on my script, ask them :slight_smile:

I don’t think you can disconnect a function, first off, I think it must be an Event, 2nd, you disconnected it before doing av = function SetupIFRame()

It can’t be an event because I want to enable a local script to change the color of the tool’s name in the backpack of each player (if the rarity is “secret”)

1 Like

Then you can’t disconnect it

But how can I fix my problem :confused:
(30 chars)

When you make a function, it has to be connected to an event for you to disconnect it

You can’t disconnect something that hasn’t been connected to anything in the first place