Only one Region3 value is working for some reason

I’m attempting to make a dynamic lighting system and I’m using a client script to detect if the player enters and leaves the Region3’s.


local Players, TweenService, Lighting, RunService = game:GetService("Players"), game:GetService("TweenService"), game:GetService("Lighting"), game:GetService("RunService")
local Regions = require(script.Regions)

local plr = Players.LocalPlayer

	for _, region in pairs(Regions) do
		local parts = workspace:FindPartsInRegion3WithWhiteList(region, plr.Character:GetChildren())

		if #parts > 0 then
			TweenService:Create(Lighting.Atmosphere,, Enum.EasingStyle.Sine), {Density = .3}):Play()
			TweenService:Create(Lighting.Atmosphere,, Enum.EasingStyle.Sine), {Density = .433}):Play()



local Regions = {
	Region1 =, 0.25, -3.75),, 7.75, 3.75)),
	Region2 =, 0.25, 4.25),, 7.76, 11.75))

return Regions

Currently, the script is only detecting the second Region3 value and not the first one for some reason. Any help is appreciated.

There’s lots of ways you could try to verify that your code does what you expect it to.

I’d start by placing parts at the corner coordinates of each region to visually see where in the world they are.

I’d then add print(_) in the for loop to see if the Region table is actually how it should be. I’d then print the number of parts in each region, and ensure that at least 1 part is in each region at all times, to verify if that works.

Attempt to print both items, what error do you receive?

1 Like

I already have a part which shows where the Region3 area is. I’ll try to print _ when Roblox is working again.

1 Like

The code looks fine. Are you sure the regions you created are in the right spots?

You might also be interested in using ZonePlus to detect when the player enters/leaves a certain area instead:

When I added a print(_) it printed
15:13:14.943 Region1 - Client - DynamnicAtmosphere:11 15:13:14.943 Region2 - Client - DynamnicAtmosphere:11

I printed the amount of parts in the first Region3 value and it printed 20 parts in both of them. It appears it isn’t changing the atmosphere density, which is what my script does for the first one and only the second.