Region3 not working properly

Hey Developers,

So I have an issue. I made a thing where whenever a player enters a zone area then it will update a GUI’s text. However, its not working properly…

Server Script Inside Zone Area Part:

local region = Region3.new(script.Parent.Position-(script.Parent.Size/2),script.Parent.Position+(script.Parent.Size/2))

local PartsInRegion = workspace:FindPartsInRegion3(region, nil, math.huge)

while wait() do
	
	for i,v in pairs(PartsInRegion) do

		local Player = game.Players:GetPlayerFromCharacter(v.Parent)

		if Player then
			
			print("H")

			game.ReplicatedStorage.ChangeZones:FireClient(Player, "Alpha")

		end

	end
	
end

Local Script:

game.ReplicatedStorage.ChangeZones.OnClientEvent:Connect(function(Zone)
	
	script.Parent.Parent.UI.ScreenZones.CurrentZone.Text = Zone
	
end)

whats the issue?

You need re-compute PartsInRegion every time you plan to update the zones, move the PartsInRegion declaration to be within the while loop.

1 Like