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

Why does my team script not work, should I use team collors?

Why does my team script not work? I am trying to make a millitary rp game and this is one of the last things I need to start it up. So please tell me what to do. Should I use team colors instead of the name?

game.Players.PlayerAdded:connect(function(player)
    if player:GetRankInGroup(2583379) == 1 then
        player.Team = "Recruit"
    elseif player:GetRankInGroup(2583379) >= 5 then
        player.Team = "1st Marine Division"
    else
end

3 answers

game.Players.PlayerAdded:connect(function(player)
    if player:GetRankInGroup(5983199) == 1 then
        player.TeamColor = BrickColor.new("Medium stone grey")--change this to the color of the recruit team
    elseif player:GetRankInGroup(5983199) >= 5 then
        player.TeamColor = BrickColor.new("Earth green")--change this to the color of the marine division tea
    else
end
end)

1 comment

0

This works

If you want to change a players team you usually change the color, so it might look like this

game.Players.PlayerAdded:connect(function(player)
    if player:GetRankInGroup(2583379) == 1 then
        player.TeamColor = BrickColor.new("")--change this to the color of the recruit team
    elseif player:GetRankInGroup(2583379) >= 5 then
        player.TeamColor = BrickColor.new("")--change this to the color of the marine division team
    else
end

5 comments

0

Hey thanks, but for some reason, I always get ranked the recruit team. But I am 253 in the group.

0

Have you tried a print statement to check if it properly checking your rank?

0

Ok Ill try that.

0

Jedi, its not printing at all, This is what I did to the script.https://pastebin.com/raw/Z7rqg684

0

one of the reasons it might not work is because you forgot the ')' on the final end on line 7, I'll continue to look for errors in case this doesn't fix the problem

As jediplocoon said you can use TeamColor. But if you want to change a player's Team using Team. You don't set it equal to the Team Name. You specifically point out the Team. Like in the example below.

local Teams = game:GetService("Teams")
local recruit = Teams:WaitForChild("Recruit")
local marine = Teams:WaitForChild("1st Marine Division")

game.Players.PlayerAdded:connect(function(player)
	if player:GetRankInGroup(2583379) == 1 then
		player.Team = recruit
	elseif player:GetRankInGroup(2583379) >= 5 then
		player.Team = marine
	end
end

1 comment

0

Hey thanks, but for some reason, I always get ranked the recruit team. But I am 253 in the group. And yes, none of the teams are the default team.

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