How can i check if a player is in zone then he is in specific team and if he leave his team change?

  1. What do you want to achieve? I want that if a player is in a specific zone (lobby zone) is in the lobby team else (if player is somewhere, but now in the lobby zone) then he is in the game team

  2. What is the issue? The script is not working especially the “else” statement (in fact it doesn’t print out of region)

local part = game.Workspace.countzone
local min = Vector3.new(part.Position.X-part.Size.X/2, part.Position.Y-part.Size.Y/2, part.Position.Z-part.Size.Z/2)
local max= Vector3.new(part.Position.X+part.Size.X/2, part.Position.Y+part.Size.Y/2, part.Position.Z+part.Size.Z/2)
local Region = Region3.new(min, max)
local players = game:GetService("Players")
local Teams = game:GetService("Teams")


while wait(1) do

	for _, part in pairs(game.Workspace:FindPartsInRegion3(Region,nil,math.huge)) do
		if part.Parent:FindFirstChild("Humanoid") ~= nil then 
		local plr = players:GetPlayerFromCharacter(part.Parent)
		if plr then
				plr.Team  = Teams.Lobby
				print("InRegion")

		
			else
				print("OutOfRegion")
				plr.Team = Teams.Game
				
	end
	end
	end
end

Ty for answers. Ask me for more informations : D

you could use zone plus

2 Likes