Hello! I am trying to make a script that turns a blur effect off. (It is stored in lighting) Please debug this script. The script is meant to turn blur on and off when a text button is clicked. (I’m a beginner scripter.)
Thank you for your time!
if the script is a server one(Script) then it would only affect how the server camera sees the things around, but not how the client sees it. If it is a client one(LocalScript) then it would affect how the local player sees but not other players or server. I think that’s what you’re aiming for.
script.Parent.MouseButton1Click:Connect(function()
end) -- Needs to be at the bottom of the function
-- Needs to be an if statement, you can't use else without one.
game.Lighting.Blur.Enabled = false
script.Parent.Text = ("Blur - Off")
else
game.Lighting.Blur.Enabled = true
script.Parent.Text = ("Blur - On")
You don’t need any if statements, this is the shortened (and more readable) code:
local Lighting = game:GetService("Lighting")
local blur = Lighting.Blur
local button = script.Parent
button.Activated:Connect(function()
blur.Enabled = not blur.Enabled
button.Text = "Blur - " .. (blur.Enabled and "Off" or "On")
end)
a = not a is a neat trick to “toggle” a boolean variable from true <-> false.