How to use TweenService to change value of FogEnd?

I’m tryna use TweenService to change the value of FogEnd so the fog comes in smoothly.

But the problem is that it doesn’t change the value of what I want it to. Instead, it changes it to 0.
The variable FogEndNew is a NumberValue and it does have value since it’s printed in the output.

Idk any solution to this for it should be working properly right?

(What Happens)
https://i.gyazo.com/74ae5a3e265c4977c02243c23addd724.mp4

Output:
image

local toTween = game.Lighting
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local goal = {}
goal.FogEnd = FogEndNew
local tween = game:GetService("TweenService"):Create(toTween, tweenInfo, goal)
tween:Play()
print("Fog's Value = "..FogEndNew)
1 Like

You could make a for loop. Example here:

local fogTarget = 100
local fog = game.Lightning.FogEnd
for i = fog, fogTarget, -.1 do
game.Lightning.FogEnd = i
wait(.1)
end

You would probably want to change the values.
Also, sorry for any typos, I’m in phone right now

Didn’t work. Thanks for the effort though.

Idk why it’s not working like it should work properly because the tween is working and the FogEndNew DOES have a value and its 500 but it still changes it to 0. E.E

--You can do this
for i = 200,100,-1 do
game.Lighting.FogEnd = i
wait(0.01)
end
1 Like

you can do this:

local tween = game:GetService("TweenService"):Create(game:GetService("Lighting"), tweenInfo, {FogEnd = the amount})
1 Like

This is how you would tween it.

local lighting = game.Lighting
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
    5, --How much time the tween lasts
    Enum.EasingStyle.Linear, --EasingStyle,
    Enum.EasingDirection.Out, --EasingDirection,
    0, --How many times it will repeat
    false, --Reverses if true
    0 --How much it gets delayed
)
local tweenFog = tweenService:Create(lighting, tweenInfo, {FogEnd = 100}) --The "100" is what you would like to set FogEnd to
tweenFog:Play()
1 Like

I figured it out. It was because my FogEnd was set to 10000000 as its origin. Somehow the TweenService couldn’t get it to 500 fast enough since its such a high number so some errors were made I guess. Thanks a lot for those who tried to help man.

2 Likes