Hello.
I am currently experimenting with Region3, and I am trying to set an area to which if the player is in, the fog will be 500 and it checks if a value is true or false. This does work, however, it shows for everybody else that plays the game, as a LocalScript. I'm very new to this and I am unsure where I went wrong.
Here's my script:
local RegionPart = workspace.RegionPart
local Pos1 = RegionPart.Position - (RegionPart.Size / 2)
local Pos2 = RegionPart.Position + (RegionPart.Size / 2)
local Region = Region3.new(Pos1, Pos2)
RegionPart:Destroy()
local Debounce = false
local Lighting = game:GetService("Lighting")
while true do
wait()
local PartsInRegion = workspace:FindPartsInRegion3(Region, nil, 1000)
for _, Part in pairs(PartsInRegion) do
if Part.Parent:FindFirstChild("Humanoid") ~= nil then
local Character = Part.Parent
if not (Debounce) then
Debounce = true
if Character.IsOutside.Value == true then
print("Character is outside, changes not applied")
else
if (Lighting.FogEnd == 120) then
Lighting.FogEnd = 500
end
end
wait(2)
Debounce = false
end
end
end
end
The LocalScript is inside StarterPlayerScripts. Thanks!

6 comments
A further note on efficiency, would be to apply ipairs here.
There seems to be an issue with the continue part, It doesn't seem to be able to get past that specific part, I've tried to swap it out with a print statement, and only then it was able to continue, also, testing with 2 clients, the fog still resets for both clients.
Oh wait I am stupid, on line 5 the character is most likely nil as its not yet loaded, what I would do is change line 26 to: if (Character ~= Gamer.Character) then... that will get current character. and yeah the ipairs is important in this case not only because of performance, but also if some part in loop becomes nil, it won't error. you should definitely use it
Okay, I'll try that, so far it seems to be going good, now I gotta hope it works with more than one client
Just as I expected, it starts to bug out when one or more players are into that region or leave
It should not have to do something with this script as it should not have problems, it could be script that [IsOutside] value or any other. What also stupid but possible could be region limit, you have it on 1000, that could explain problem with other clients but the first option is most likely i think. Otherwise i don't know.