Is there a way to make something not spawn if the value = false?

I am making a night system table and trying to make the fog system but the only problem is when the NightFog = false the Fog still spawns when it shouldn’t also does math.random need a number to work

My script

-- Before the Night starts
local NightHint = {
	NightName = "Night 1",
	NightFog = false,
	BloodMoon = false, -- Boost Zombies damage + walkspeed
	BlueMoon = false, -- Boosts Players Gun Damage
	GreenMoon = false, -- Boosts Players health + walkspeed
	PurpleMoon = false, -- Decreases Zombies health + walkspeed
}

wait(10)
NightHint["NightFog"] = math.random
NightHint["BloodMoon"] = math.random
NightHint["BlueMoon"] = math.random
NightHint["GreenMoon"] = math.random
NightHint["PurpleMoon"] = math.random

for NightPicked, value in pairs(NightHint) do
	print(value)
end

for NightFog, value in pairs(NightHint) do -- Fog System
	wait(1)
	local lighting = game:GetService("Lighting")
	lighting.FogStart = 1
	lighting.FogEnd = 100
	lighting.FogColor = Color3.fromRGB(171, 168, 158)
	local NightFog = NightFog
	if NightHint.Value == false then
	lighting.FogStart = 1000
	lighting.FogEnd = 100
	lighting.FogColor = Color3.fromRGB(248, 248, 248)
	end
end
NightHint["NightFog"] = math.random(1,2) == 1 and true or false
NightHint["BloodMoon"] = math.random(1,2) == 1 and true or false
NightHint["BlueMoon"] = math.random(1,2) == 1 and true or false
NightHint["GreenMoon"] = math.random(1,2) == 1 and true or false
NightHint["PurpleMoon"] = math.random(1,2) == 1 and true or false

or

for Index, Value in pairs(NightHint) do
	if type(Value) == "boolean" then
		NightHint[Index] = math.random(1,2) == 1 and true or false
	end
end
2 Likes