Hello there. I wanted to make an effect that would have the blur increase and decrease, giving an illusion of extreme heat.
The problem is, that the script just isn’t working. I’ve detected that the main problem is in my referencing, but I’m still very confused on how to make this work.
I want to know if I am doing anything wrong… Sorry if this is an incorrect category or anything, I’m still somewhat new to the forums.
local blur = 0
local blurEffect = game.Lighting:FindFirstChild("Blur").Size
print("started the blur effect")
while true do
blurEffect = blur
repeat
blurEffect = blur + 1
blur = blurEffect
print("changed blur by 1")
wait(1)
until blur == 3
repeat
blurEffect = blur - 1
blur = blurEffect
print("changed blur by -1")
wait(1)
until blur == 0
blurEffect = blur
end
It looks like you’re unintentionally storing the value of the current blur in a local variable, instead of the reference the value. Whenever you do something like this local blurEffect = game.Lighting:FindFirstChild("Blur").Size, you’re copying the Size attribute of the blur object into a new variable called blurEffect. The keyword here is copying. In order to reference that attribute and change it, you have to access the attribute in the Blur object every time.
game.Lighting.Blur.Size = blurEffect
You can store references to objects and tables, but for primitive data types like numbers and booleans, lua automatically clones the data when you create a new local variable “referencing” a piece of data.
An example of storing a reference to the object and using it how you’d like to is like this:
local blurObject = game.Lighting:FindFirstChild("Blur")
...
blurObject.Size = xyz
Just saying: I’m not sure if you’re doing it this way because you explicitly need the rigid effect or if you can settle for a different method but TweenService can handle this for you. Bonus point is that it has an argument for repeating so you don’t need to use a loop at all.
local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")
-- Make sure the Size is set to 0
local BlurEffect = Lighting:WaitForChild("Blur")
-- New lining just for readability, I don't always do this.
local TWEEN_INFO = TweenInfo.new(
3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out,
-1, true, 0
)
-- Make this the Size you want a fully blurred screen to be
local BLUR_TARGET = 15
TweenService:Create(BlurEffect, TWEEN_INFO, {Size = BLUR_TARGET}):Play()
You can adjust this script later if you have any further needs. For example if you want to stop the effect then you can call cancel on the tween and set the Size back to 0, or whatever you like in terms of getting the effect to reset.
Sorry, I made a couple of silly mistakes in my script which were corrected. I also have a repro file if you’d like which contains a working sample of the code.
You don’t need my permission. Feel free to use it, that’s why I gave it. Code and advice I give on threads are always free to be used, that’s why I give it to begin with.