Is there away to get this done? I am also looking for away to make it so only a rank can join a team so admins can’t just use :team me cafe to get on that team they have to be a rank inorder to do so.
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local ProtectedCall = pcall
local GroupId = 0 --Change to group ID.
local GroupRank = 0 --Change to group rank required.
local Team = Teams:FindFirstChild("Neutral") --Change to name of team.
Players.PlayerAdded:Connect(function(Player)
local Success1, Result1 = ProtectedCall(function()
return Player:IsInGroup(GroupId)
end)
if Success1 then
if Result1 then
local Success2, Result2 = ProtectedCall(function()
return Player:GetRankInGroup(GroupId)
end)
if Success2 then
if Result2 >= GroupRank then
Player.Team = Team
end
else
warn(Result2)
end
end
else
warn(Result1)
end
end)
You mean a script which auto-assigns a player’s team based on what rank they are within a group? The above script achieves that task.
No, I mean a rank tag but on teams you can put a group id and it will show the rank for that team. Like for Chris’s Cafe it would have there ranks with its group for that team only.
You are going to have to make a system to house the group IDs. Here’s how it’ll sort of look like:
local Players = game.Players
local Team_Table = {
-- ["Team Name"] = {Group ID, Minimum Rank, Max Rank}
-- Team name MUST match the team instance in game.Teams
["Team Graphite"] = {000000000,1,255};
["Team Blue"] = {111111111,1,255};
["Team Red"] = {222222222,1,255};
}
local function Authenticate_Player(player:Player,teamName:string)
-- We check whether if the player is in this group and matches the conditions.
local result
local args = {
GroupID = Team_Table[teamName][1];
MinRank = Team_Table[teamName][2];
MaxRank = Team_Table[teamName][3];
}
if player:IsInGroup(args.GroupID) and player:GetRankInGroup(args.GroupID) >= args.MinRank and player:GetRankInGroup(args.GroupID) <= args.MaxRank then
result = true
else
result = false
end
return result
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
local playerTeam = player.Team
-- We will now check if the team exists in the table we made above
for teamName, teamData in pairs(Team_Table) do
if playerTeam == teamName then
local result = Authenticate_Player(player,playerTeam.Name)
if result == true then
-- Do your stuff
else
return
end
end
end
end)
end)
Keep in mind that this is a sample code and you need to do a lot of tweaking.
This code was not tested with real groups either, though confirmed that there are neither syntax errors or logic errors.