Script spewing out errors in output

Whenever I start my game, there is this error message in the output

Here is my script

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)

Here is another image
image

Hope somebody can help me!

sorry, can i ask what type of instance “WaterLevel” (in the workspace) is?

Its a part

(char limitllllllllllllllll)

you set “CFrame_v0” to 0 in line 16, it won’t have a “Y”, did you reuse the variable name by accident?

I think I might have

(char limittttttttttt)

How would I fix the error from the script? Thats mainly what I need to know.

The issue is because you’re setting CFrame_v0 to 0 before the if statement, also is this code stolen because it resembles decompiled code

2 Likes

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

uhhhhhhhhhhhhhhhhhhhhhhh
maybe

might be from nds

Smh instead of skidding code you should learn how to make it yourself so you actually know how to improve and or fix it

1 Like

^^ 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

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.