Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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                                           
0
elseif in line 9 is underlined in read ANDREW50060 1 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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.

0
did not work i used elseif .-. ANDREW50060 1 — 6y
0
It should, you're just inexperienced. You'll get there. User#19524 175 — 6y
0
i fixed it ANDREW50060 1 — 6y
Ad
Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago

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()
0
Hope this helps! hellmatic 1523 — 6y

Answer this question