Hai, i’ve been trying to add tweenservice to this script, its supposed to create a raincycle. I wanted the TweenService to make the effects such as colorcorrection, atmosphere or depthoffield to be enabled really smoothly. However, the script seems to be bugging and not working properly, how do i fix this?
The Script:
--locals
local Brightness = game.Lighting.Brightness
local DepthOfFieldValue = game.Lighting.DepthOfField2.FarIntensity
local ColorCorrectionBrightness = game.Lighting.ColorCorrection2.Brightness
local ColorCorrectionContrast = game.Lighting.ColorCorrection2.Contrast
local ColorCorrectionSaturation = game.Lighting.ColorCorrection2.Saturation
local AtmosphereDensity = game.Lighting.Atmosphere.Density
local RainStraightRate = script.Parent.Parent.Parent.Parent.Workspace.Camera.__RainEmitter.RainStraight.Rate
local RainTopDownRate = script.Parent.Parent.Parent.Parent.Workspace.Camera.__RainEmitter.RainTopDown.Rate
local RainVolume = script.Parent.Parent.Parent.Parent.SoundService.__RainSoundGroup.Volume
local RainScriptEnabled = script.Parent.RainScript.Enabled
local TweenService = game:GetService('TweenService')
local lighting = game.Lighting
function RainCycle()
-- Start with default values
Brightness = 6
DepthOfFieldValue = 0
ColorCorrectionBrightness = 0
ColorCorrectionContrast = 0
ColorCorrectionSaturation = 0
AtmosphereDensity = 0.33
RainStraightRate = 0
RainTopDownRate = 0
RainVolume = 0
-- This is what we want to happen during/after tween
Brightness = 1
DepthOfFieldValue = 0.05
ColorCorrectionBrightness = 0.1
ColorCorrectionContrast = 0.1
ColorCorrectionSaturation = 0.5
AtmosphereDensity = 0.45
RainStraightRate = 400
RainTopDownRate = 400
RainVolume = 20
-- Create tween info
local tweenInfo = TweenInfo.new(30) -- Change 1.5 to however long you want the tween to take
-- Create tween
local tween = tweenService:Create(Lighting, tweenInfo, tweenValues)
tween:Play() -- Play tween
end
while true do
if (math.random(1,60) == 2) then RainCycle() end --Change this to a higher number and it won't start raining as likely, for an example "(1,200) == 2)"
wait(2)
end
local tween = tweenService:Create(Lighting, tweenInfo, tweenValues)
It should be:
local tween = TweenService:Create(lighting, tweenInfo, tweenValues)
These variables weren’t referenced correctly. Not to mention the fact that twen values aren’t defined in the script, so I can’t even debug this properly.
I have no clue where your variables are leading but check because I don’t have access to the game they might be wrong, as for the rain starting right away, are u sure ur not calling the func urself from somewhere else?