Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

In game teaming script does not team besides specator?? Would love/need some help fixing it

game.Players.PlayerAdded:connect(function(player)
        if player:GetRankInGroup(2533886) == 8 then
                player.TeamColor = game.Teams.Security.TeamColor
        
                elseif player:GetRankInGroup(2533886) >= 1 then
                        player.TeamColor = game.Teams.Models.TeamColor

                        game.Players.PlayerAdded:connect(function(player)
                               elseif player:GetRankInGroup(2533886) == 0 then
                                        player.TeamColor = game.Teams.Spectators.TeamColor
                                
                                        game.Players.PlayerAdded:connect(function(player)
                                                elseif player:GetRankInGroup(2533886) >= 12 then
                                                        player.TeamColor = game.Teams.HighRanks.TeamColor                                           

1 comment

0

elseif in line 9 is underlined in read

2 answers

Your code is very illegible. Your current code says if the player who joins' rank is >=1, then do your code, but if they are < 1, then it listens for a DIFFERENT player to join and do the same process? Use elseif.

3 comments

0

did not work i used elseif .-.

0

It should, you're just inexperienced. You'll get there.

0

i fixed it

Paste this in a LocalScript and place it in StarterPlayerScripts.

repeat wait() until game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(workspace)
--------------------------------------------------------------------------------------------------------------

--GET SERVICES
local Players = game:GetService('Players')

--CONSTANTS
local Player = Players:WaitForChild(game.Players.LocalPlayer.Name)
local Character = Player.Character

--TEAMS
local GroupID = 2533886

local SecurityTeam = game.Teams.Security
local ModelTeam = game.Teams.Models
local SpectatorTeam = game.Teams.Spectators
local HighRanksTeam = game.Teams.HighRanks

--VARIABLES
local GroupRank = nil 

--SET TEAM FUNCTION
function SET_TEAM()
	GroupRank = Player:GetRankInGroup(GroupID)

	if GroupRank == 8 then 
		Player.TeamColor = SecurityTeam.TeamColor
	
	elseif GroupRank >= 1 then 
		Player.TeamColor = ModelTeam.TeamColor

	elseif GroupRank == 0 then 
		Player.TeamColor = SpectatorTeam.TeamColor

	elseif GroupRank >= 12 then 
		Player.TeamColor = HighRanksTeam.TeamColor
	end

	Player:LoadCharacter()
end

SET_TEAM()

1 comment

0

Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.