local LightingService_v0 = game:GetService("Lighting")
local upval1 = workspace:WaitForChild("WaterLevel")
local upval2 = script:WaitForChild("WaterAtmosphere")
game:GetService("RunService"):BindToRenderStep("UnderwaterCamera", Enum.RenderPriority.Camera.Value + 1, function()
local CurrentCamera_v0 = workspace.CurrentCamera
if CurrentCamera_v0 then
local y_v0 = CurrentCamera_v0.CFrame.Y
local var1 = workspace:FindFirstChild("Structure")
if var1 then
local var0 = var1:FindFirstChild("FloodLevel")
if var0 then
local y_v1 = var0.CFrame.Y
end
end
local CFrame_v0 = upval1.CFrame
CFrame_v0 = 0
if y_v0 < math.max(CFrame_v0.Y, CFrame_v0) then
upval2.Parent = LightingService_v0
end
upval2.Parent = script
end
end)
i also found an issue with the atmosphere not staying in lighting after, i fixed that below
local LightingService_v0 = game:GetService("Lighting")
local upval1 = workspace:WaitForChild("WaterLevel")
local upval2 = script:WaitForChild("WaterAtmosphere")
game:GetService("RunService"):BindToRenderStep("UnderwaterCamera", Enum.RenderPriority.Camera.Value + 1, function()
local CurrentCamera_v0 = workspace.CurrentCamera
if CurrentCamera_v0 then
local y_v0 = CurrentCamera_v0.CFrame.Y
local var1 = workspace:FindFirstChild("Structure")
if var1 then
local var0 = var1:FindFirstChild("FloodLevel")
if var0 then
local y_v1 = var0.CFrame.Y
end
end
local CFrame_v0 = upval1.CFrame
local minimumY = 0 --this should fix the issue you had. this value is the minimum Y before atmosphere change takes place (which is 0, as per your code)
if y_v0 < math.max(CFrame_v0.Y, minimumY) then
upval2.Parent = LightingService_v0 -- atmosphere gets moved into lighting if camera Y is below "WaterLevel" or minimumY (0)
else
upval2.Parent = script -- atmosphere goes back into script if above is false
end
end
end)
also this is probably really inefficient, there’s probably another way that doesn’t involve checking every step, and might not work depending on how ur game is set up
^^ yes, you should create code yourself and learn, but looking over past code isn’t bad way to learn as long as you are ACTUALLY learning
also don’t be afraid to ask questions here either