This is a localscript that blurs the screen of the player and disables saturation while the player is in the esc menu, this is how it works.
--CODED BY V1SIONUSE--
--PUT IN STARTERGUI--
--CREATE A "COLORCORRECTION" EFFECT IN LIGHTING FIRST--
local GuiService = game:GetService("GuiService")
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
repeat
wait()
until workspace.CurrentCamera
local Camera = workspace.CurrentCamera
local originalSaturation = Lighting.ColorCorrection.Saturation
GuiService.MenuOpened:Connect(function()
local blur = Instance.new("BlurEffect")
blur.Size = 0 -- Start with no blur
blur.Parent = Camera
local tweenInfo = TweenInfo.new(0.5) -- Set the duration of the tween (in seconds)
local tween = TweenService:Create(blur, tweenInfo, { Size = 20 }) -- Tween the blur size from 0 to 20
tween:Play() -- Start the tween
local saturationTween = TweenService:Create(Lighting.ColorCorrection, tweenInfo, { Saturation = -1 }) -- Tween the saturation from its original value to -1
saturationTween:Play() -- Start the saturation tween
GuiService.MenuClosed:Connect(function()
local reverseTween = TweenService:Create(blur, tweenInfo, { Size = 0 }) -- Tween the blur size from 20 back to 0
reverseTween:Play() -- Start the reverse tween
reverseTween.Completed:Connect(function()
blur:Destroy() -- Destroy the blur effect once the reverse tween is completed
local reverseSaturationTween = TweenService:Create(Lighting.ColorCorrection, tweenInfo, { Saturation = originalSaturation }) -- Tween the saturation back to its original value
reverseSaturationTween:Play() -- Start the reverse saturation tween
end)
end)
end)
This line will lead to loads of connections being made you should switch it to :Once instead of :Connect or take the line out of the MenuOpened connection so that only 1 connection is made
Also minor performance thing but there’s no need to create and destroy the blur objects / tweens every time, you can just make them once at the start of the script and reuse them
Thanks for providing this script! There are some functional issues with it, though, as others have noted. I made a small update to the script to fix a few of these issues:
-- written by V1SIONUSE
-- updated by AverageLua
local GuiService = game:GetService("GuiService")
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
local ColorCorrectionEffect = Instance.new("ColorCorrectionEffect", Lighting)
local BlurEffect = Instance.new("BlurEffect", Lighting)
BlurEffect.Size = 0
local MenuEffectTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
local BlurEffectSize = 20
local ColorCorrectionSaturation = -1
local function MenuOpened()
TweenService:Create(BlurEffect, MenuEffectTweenInfo, {
Size = BlurEffectSize
}):Play()
TweenService:Create(ColorCorrectionEffect, MenuEffectTweenInfo, {
Saturation = ColorCorrectionSaturation
}):Play()
end
local function MenuClosed()
TweenService:Create(BlurEffect, MenuEffectTweenInfo, {
Size = 0
}):Play()
TweenService:Create(ColorCorrectionEffect, MenuEffectTweenInfo, {
Saturation = 0
}):Play()
end
GuiService.MenuOpened:Connect(MenuOpened)
GuiService.MenuClosed:Connect(MenuClosed)
(place this in a LocalScript within StarterPlayerScripts!)
Since it creates them on its own, this version doesn’t require any objects to be added to the Lighting service. Additionally, it prevents any potential memory leakage associated with GuiService event connections.
--CODED BY V1SIONUSE--
--PUT IN STARTERGUI--
--CREATE A "COLORCORRECTION" EFFECT IN LIGHTING FIRST--
local GuiService = game:GetService("GuiService")
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
repeat
wait()
until workspace.CurrentCamera
local Camera = workspace.CurrentCamera
local originalSaturation = Lighting.ColorCorrection.Saturation
-- Create the blur effect once at the start
local blur = Instance.new("BlurEffect")
blur.Size = 0 -- Start with no blur
blur.Parent = Camera
-- Create the tweens once at the start
local tweenInfo = TweenInfo.new(0.5) -- Set the duration of the tween (in seconds)
local tween = TweenService:Create(blur, tweenInfo, { Size = 20 }) -- Tween the blur size from 0 to 20
local reverseTween = TweenService:Create(blur, tweenInfo, { Size = 0 }) -- Tween the blur size from 20 back to 0
GuiService.MenuOpened:Connect(function()
tween:Play() -- Start the blur tween
local saturationTween = TweenService:Create(Lighting.ColorCorrection, tweenInfo, { Saturation = -1 }) -- Tween the saturation from its original value to -1
saturationTween:Play() -- Start the saturation tween
GuiService.MenuClosed:Once(function()
reverseTween:Play() -- Start the reverse blur tween
reverseTween.Completed:Connect(function()
local reverseSaturationTween = TweenService:Create(Lighting.ColorCorrection, tweenInfo, { Saturation = originalSaturation }) -- Tween the saturation back to its original value
reverseSaturationTween:Play() -- Start the reverse saturation tween
end)
end)
end)
Hi! I used a colorcorrection cause if a game has modified the saturation of their game with a colorcorrection, it has to keep that value when going out of the menu
Here is a better script which changed unnecessary connections:
--CODED BY V1SIONUSE--
--PUT IN STARTERGUI--
--CREATE A "COLORCORRECTION" EFFECT IN LIGHTING FIRST--
local GuiService = game:GetService("GuiService")
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
local Camera = workspace.CurrentCamera or workspace:GetPropertyChangedSignal("CurrentCamera"):Wait()
local originalSaturation = Lighting.ColorCorrection.Saturation
GuiService.MenuOpened:Connect(function()
local blur = Instance.new("BlurEffect")
blur.Size = 0 -- Start with no blur
blur.Parent = Camera
local tweenInfo = TweenInfo.new(0.5) -- Set the duration of the tween (in seconds)
local tween = TweenService:Create(blur, tweenInfo, { Size = 20 }) -- Tween the blur size from 0 to 20
tween:Play() -- Start the tween
local saturationTween = TweenService:Create(Lighting.ColorCorrection, tweenInfo, { Saturation = -1 }) -- Tween the saturation from its original value to -1
saturationTween:Play() -- Start the saturation tween
GuiService.MenuClosed:Once(function()
local reverseTween = TweenService:Create(blur, tweenInfo, { Size = 0 }) -- Tween the blur size from 20 back to 0
reverseTween:Play() -- Start the reverse tween
reverseTween.Completed:Once(function()
blur:Destroy() -- Destroy the blur effect once the reverse tween is completed
local reverseSaturationTween = TweenService:Create(Lighting.ColorCorrection, tweenInfo, { Saturation = originalSaturation }) -- Tween the saturation back to its original value
reverseSaturationTween:Play() -- Start the reverse saturation tween
end)
end)
end)
How? It makes one connection? And then when a script is destroyed (when the character dies) the connections also get disconnected. So its not like its duplicating scripts and their connections.
What if the user opens, closes and then reopens the menu? It will just stop working?
However I would suggest placing it in StarterPlayerScripts instead since what if the character hasnt loaded in an is in a menu? The script would not have fired and the blur effect wouldn’t work.
I agree with this although it is a very minor improvement