What I'm trying to figure out is how to make these scripts to work.
I have a folder full of scripts as such
local team = "Students" game.Players.PlayerAdded:connect(function (Player) if Player:IsInGroup(#####) and Player:GetRankInGroup(1) then Player.TeamColor = game:GetService("Teams")[team].TeamColor if Player.Character then Player.Character.Humanoid.Health = 0 end end end)
What doesn't happen is other ranks getting put in their said teams. What I see is happening, is that the scripts obviously overlap since the higher ranks can also be put into the lower ranks teams.
Question being asked is how do I un-overlap them/ make them work so each rank gets put in the said team.
The problem with your script is that the line:
lua
if Player:IsInGroup(#####) and Player:GetRankInGroup(1) then
doesn't actually check for a corresponding rank, it just checks if the player has a rank, which is redundant since Player:IsInGroup()
automatically tells us the player has a rank, default rank or not.
There are two ways you can approach this, you can - Name all teams to whatever their corresponding role is - Write up a table that has each rank and it's corresponding team
I would recommend using the first option since then it's easier for players to recognize ranks and it saves you the work to write up the whole table.
```lua local group = 123456789 local teams = { -- Example: -- 1 = "Noob", -- 2 = "Beginner", -- 255 = "Master!" -- 220 = "Chairman" -- etc. LowestRank = LowestRoleTeam, SecondLowestRank = SecondLowestRoleTeam, ThirdLowestRank = ThirdLowestRoleTeam, -- and so on }
game.Players.PlayerAdded:Connect(function(player) if player:IsInGroup(group) then player.Team = teams[player:GetRankInGroup(group)] end end) ```
```lua local group = 123456789
game.Players.PlayerAdded:Connect(function(player) if player:IsInGroup(group) then player.Team = game:GetService("Teams"):FindFirstChild(player:GetRoleInGroup(group)) end end) ``` Note: No need to duplicate these scripts, an individual script will do the job
Please comment if I have made any mistakes or you have any questions