I know this is not a request site but I honestly have no clue. I have been trying to do this for the past 4 hours. I can't find anything on the internet that helped.
This is what I have so far:
Players = game:GetService("Players") for i, player in pairs(Players:GetPlayers()) do -- This is where I'm stuck end
Is this what you want?
local Team = Wherever the team is located local player = Team:GetPlayers() if #player == 1 then print("1 player found in Team") --run rest of code here end
To detect if one player is on a certain team all you need is the player's name. A player has a property that determines the team it is on, so you can check that way.
If PlayerName.Team == game.Teams.TeamName then --do stuff end
As far as I'm sure, this method is for server side only.
There is a Player.Team property inside the player.
so you would do:
local PlayerOnTeam = 0 for _,i in pairs(game.Players:GetChildren()) do if i.Team == game.Team.Teamname then PlayerOnTeam = PlayerOnTeam + 1 end end if PlayerOnTeam = 1 then do thing if only one player end
game.Players.PlayerAdded:Connect(function(p) if p.Team == ("TeamName) then -- Code end end)
An easy solution would be to fire a remoteFunction or remoteEvent depending on what you want the result to be, but here is a way to find the player's team
function onPlayerAdded(player) if player.Team == ("YourTeamName") then --Your code. end end) game.Players.PlayerAdded:Connect(onPlayerAdded)
If this doesn't work I'm sorry but i was typing this from memory and haven't actually tested it out on studio.