Hi devforum, I’m having problems with my Local Environment Script. When your ship enters a planet (a Region3), the lighting changes then goes back to the default almost immediately as shown in the video below.
I don’t understand why I have this issue, I have tried researching all over the web but could not find any solution to what I have. Any help is appreciated, thank you.
Code:
while true do wait(.25)
for i,v in pairs(game.Workspace:GetDescendants()) do
if v.Name == "LocalEnvironment" then
local regionPart = v
local region = Region3.new(regionPart.Position-(regionPart.Size/2), regionPart.Position+(regionPart.Size/2))
local obj = workspace:FindPartsInRegion3(region,nil,math.huge)
for i,parts in pairs(obj) do
if parts.Parent.Parent.Parent == game.Workspace.GaloidWorkspace.PlayerShips:FindFirstChild(player.Name) then
if inenvironment == false then
inenvironment = true
enter(v)
end
else
if inenvironment == true then
inenvironment = false
exit(v)
end
end
end
end
end
end