Problem occurred when disabling a local script

  1. What do I want to achieve:

I made a Text button and put a local script inside which disables a Film Grain local script in Starter GUI when clicked.

  1. What is the issue?

The local script is working and disabling the Film Grain script but the film grain effect is not disabling. I mean that the Script is being disabled but the effect is still there even when the script is disabled.

  1. What solutions have you tried so far?

I’ve found a script from Developer Hub but still, the film grain effect is not disabling but the script is disabled.

SCRIPT WHICH IS USED TO DISABLE THE FILM GRAIN SCRIPT:

local FilmGrain = game.StarterGui.FilmGrain
local textButton = script.Parent

-- Initialize the state of the button
textButton.Text = "Turn OFF Film Grain effect!"
textButton.Font = "Code"


local function onActivated()
	
	FilmGrain.Disabled = true
end

-- Connect the "Activated" event to our function
textButton.Activated:Connect(onActivated)

THE ERROR WHICH IS SHOWING IN THE OUTPUT:

replace Script to LocalScript, and try again!

It is working but since you put game.StarterGui.FilmGrain. it will only disable the script in StarterGui. Try using the PlayerGui in client

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local FilmGrain = playerGui.FilmGrain

local textButton = script.Parent

-- Initialize the state of the button
textButton.Text = "Turn OFF Film Grain effect!"
textButton.Font = "Code"

local function onActivated()
	
	FilmGrain.Disabled = true
end

-- Connect the "Activated" event to our function
textButton.Activated:Connect(onActivated)

Edit: i forgot to put some things of in the script

1 Like

Tried, but still doesn’t work. Btw, both the scripts should be in “Local script” only or else they don’t work.

Yes! It’s working!! Thank you so much for helpin’ me out :>

No problem! im happy to help :smile:

1 Like

Btw, is there any way by which we can change script values like true or false using another script?

you can but the script with the values(variables) is placed on a module script.

oh, okay! I asked bcz the film grain effect is disabled but the grain particles are still on the screen without moving and it is very looking awkward.

I don’t know if you can see that blurry particles effect on the screen… It’s not looking good.