I just made a very basic clicker game, and added a localscript which can detect a players country when joining the game (exactly this : https://developer.roblox.com/en-us/api-reference/function/LocalizationService/GetCountryRegionForPlayerAsync ), i put it in the Starterplayerscripts because its the only way it works. So the main thing is : i want to assign players automatically to a specified team by their country, like if a player joins from Canada then he will be assigned to the "Canada" team, i want to do this but with like 100+ teams(countries). I tried everything today, i just cant figure it out to work sadly. Can somebody please help me to do it? Much thanks!
What you could do is check if the Team/Country already exists in the Team service, in the scenario where it doesn't, it'll create an entire new team and place the player inside of that team, but if the team does already exist, it'll place them in the team.
local players = game:GetService("Players") local LS = game:GetService("LocalizationService") local teams = game.Teams local function createTeam(name) local newTeam = Instance.new("Team") newTeam.Name = name newTeam.Parent = teams return newTeam end players.PlayerAdded:Connect(function(player) local foundRegion = LS:GetCountryRegionForPlayerAsync(player) if teams:FindFirstChild(foundRegion) == nil then local createdTeam = createTeam(foundRegion) player.Team = createdTeam else player.Team = teams:FindFirstChild(foundRegion) end end)
I tested this and it worked. I'm not the best scripter, but hopefully this helps!