Hello, I have this script, which changes the Brightness, Fog and OutDoorAmbient of the game when you touch it.
My problem is: It instantly switches, how do I make it go more smoothly?
local lighting = game.Lighting script.Parent.Touched:Connect(function() lighting.Brightness = 0 lighting.FogStart = 50 lighting.FogColor = Color3.new(0,0,0) lighting.OutdoorAmbient = Color3.new(0,0,0) end)
It's a very simple script but I don't know how to do this kind of stuff. Thanks for your help
you could use a loop to gradually change their properties
local lighting = game.Lighting script.Parent.Touched:Connect(function() local num1 = 0 while num1 <= 50 do lighting.Brightness = lighting.Brightness -1 lighting.FogStart = lighting.FogStart + 1 lighting.FogColor = Color3.new(0+1, 0+1, 0+1) lighting.OutdoorAmbient = Color3.new(0+1, 0+1, 0+1) num1 = num1 + 1 wait(0.1) end end)
For each property you would put the number they started at and then add or subtract 1 depending on what number you would want to end up on
you could also use a for loop
Sorry for my sloppy code! To change the speed go to Speed and change it to the time you want (In seconds)!
local lighting = game.Lighting local Debounce = false local Speed = 1 local function Tween(t,s,d,p,o) return game:GetService("TweenService"):Create(o,TweenInfo.new(t,Enum.EasingStyle[s],Enum.EasingDirection[d]),p) end script.Parent.Touched:Connect(function() if not Debounce then Debounce = true Tween(Speed,"Sine","InOut",{Brightness = 0,FogStart = 50,FogColor = Color3.fromRGB(0,0,0),OutdoorAmbient = Color3.fromRGB(0,0,0)},lighting):Play() end end)