Group Rank Team Changer Module

I’ve been trying to make a secured group rank team and for some reason this isn’t working right. Am I doing it right or wrong?

SCRIPT:

game.ReplicatedStorage.Events.TeamEvent.OnServerEvent:Connect(function(player, Team)
    	if Team == "Toddler" then
    		player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor	
    		player:LoadCharacter()
    	elseif Team == "Nurse" then
    		if player:GetRankInGroup(5251616) == 3 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "Assistant Teacher" then
    		if player:GetRankInGroup(5251616) == 4 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor	
    			player:LoadCharacter()	
    	elseif Team == "Teacher" then
    		if player:GetRankInGroup(5251616) == 5 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "Supervisor" then
    		if player:GetRankInGroup(5251616) == 6 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "School Counselor" then
    		if player:GetRankInGroup(5251616) == 7 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "School Administrator" then
    		if player:GetRankInGroup(5251616) == 8 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "Vice Principal" then
    		if player:GetRankInGroup(5251616) == 9 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "Principal" then
    		if player:GetRankInGroup(5251616) == 10 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "Headmaster" then
    		if player:GetRankInGroup(5251616) == 11 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "Superintendent" then
    		if player:GetRankInGroup(5251616) == 12 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    	elseif Team == "Vice President" then
    		if player:GetRankInGroup(5251616) == 13 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    	elseif Team == "President" then
    		if player:GetRankInGroup(5251616) == 14 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    													end
    												end
    											end
    										end
    									end
    								end
    							end
    						end
    					end
    				end				
    			end
    		end	
    	end
    end)
3 Likes

Your if statements look all screwed up. You are putting the start of if statements inside the elseifs, but putting their ends and the very end of the function. This is making your code one giant nested if statement mess.

Try this:

game.ReplicatedStorage.Events.TeamEvent.OnServerEvent:Connect(function(player, Team)
    	if Team == "Toddler" then
    		player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor	
    		player:LoadCharacter()
    	elseif Team == "Nurse" then
    		if player:GetRankInGroup(5251616) == 3 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    		end
    	elseif Team == "Assistant Teacher" then
    		if player:GetRankInGroup(5251616) == 4 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor	
    			player:LoadCharacter()	
    		end
    	elseif Team == "Teacher" then
    		if player:GetRankInGroup(5251616) == 5 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end	
    	elseif Team == "Supervisor" then
    		if player:GetRankInGroup(5251616) == 6 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end	
    	elseif Team == "School Counselor" then
    		if player:GetRankInGroup(5251616) == 7 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end	
    	elseif Team == "School Administrator" then
    		if player:GetRankInGroup(5251616) == 8 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    		end
    	elseif Team == "Vice Principal" then
    		if player:GetRankInGroup(5251616) == 9 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()		
    		end
    	elseif Team == "Principal" then
    		if player:GetRankInGroup(5251616) == 10 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end	
    	elseif Team == "Headmaster" then
    		if player:GetRankInGroup(5251616) == 11 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end	
    	elseif Team == "Superintendent" then
    		if player:GetRankInGroup(5251616) == 12 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end	
    	elseif Team == "Vice President" then
    		if player:GetRankInGroup(5251616) == 13 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end
    	elseif Team == "President" then
    		if player:GetRankInGroup(5251616) == 14 then
    			player.TeamColor = game.Teams:FindFirstChild(Team).TeamColor
    			player:LoadCharacter()	
    		end
    	end
end)

4 Likes

Thank you, this new script works.

1 Like