Need help with script not working

I’m making a FNaF game, and while making something i ran into an error that shouldn’t be happening.

Error: Darkness is not a valid member of Model “Workspace.LightsOut”
Script:

local LocalPlayer = game.Players.LocalPlayer;
local StarterGui = game:GetService("StarterGui");

wait(5);
StarterGui:SetCore("ResetButtonCallback", false);
while true do
	wait();
	if game.Workspace:FindFirstChild("LightsOut") then
		local var1 = game.SoundService.Music.PlaybackLoudness / 125;
		if var1 <= 0.33 then
			workspace.LightsOut.Darkness.Transparency = 0;
		end;
		if var1 >= 0.34 then
			workspace.LightsOut.Darkness.Transparency = workspace.SoundService.Music.PlaybackLoudness / 125;
		end;
		wait(0.055);
	end;
end;```

Darkness is a member of workspace.LightsOut.

First thing first, assuming everything in the code is functional, you may want to compare the names of the objects within workspace that you are dealing with to those within the script. I’m sure you’ve already done this; however, you’d be surprised at how many times a simple typo has caused me to lose my mind.

Another possibility could be that you have multiple LightsOut objects and the one being connected to by the script does not contain Darkness.

The last simple issue I could think of is that “Darkness” is made by a another script and hence is not initially inside of the LightsOut object.

local LocalPlayer = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
local soundService = game:GetService("SoundService")
local rs = game:GetService("RunService")
StarterGui:SetCore("ResetButtonCallback", false)
local lightsOut = workspace:WaitForChild("LightsOut")
local darkness = lightsOut:WaitForChild("Darkness")
local sound = soundService:WaitForChild("Music")

sound:Play()

rs.RenderStepped:Connect(function()
	if sound.PlaybackLoudness <= 125 then
		darkness.Transparency = 0
	elseif sound.PlaybackLoudness > 125 then
		darkness.Transparency = 1
	end
	print(darkness.Transparency)
end)

I know these aren’t the values you wanted, I just replaced them for testing, this is working for me, here’s the place file if you’d like to check it out.

example.rbxl (27.0 KB)