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.
LocalScript:
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
RunService.Stepped:Connect(function()
for _, region in pairs(Regions) do
local parts = workspace:FindPartsInRegion3WithWhiteList(region, plr.Character:GetChildren())
if #parts > 0 then
TweenService:Create(Lighting.Atmosphere, TweenInfo.new(.5, Enum.EasingStyle.Sine), {Density = .3}):Play()
else
TweenService:Create(Lighting.Atmosphere, TweenInfo.new(.5, Enum.EasingStyle.Sine), {Density = .433}):Play()
end
end
end)
ModuleScript:
local Regions = {
Region1 = Region3.new(Vector3.new(-35.75, 0.25, -3.75), Vector3.new(-28.25, 7.75, 3.75)),
Region2 = Region3.new(Vector3.new(-35.75, 0.25, 4.25), Vector3.new(-16.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.