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

Help what is wrong in this group/team changer code?

game.Players.PlayerAdded:connect(function(player) -- function is called when player joins game
    if player:GetRankInGroup(4980928) >= 238 then --checks if players rank in 2671856 is greater than or equal to 8
        player.Team = "United States Military" -- sets players team to officers
    elseif player:GetRankInGroup(4980928) < 238 then -- checks if players rank in 2671856 is smaller than 8
        player.Team = "Basic Combat Training" -- sets players team to unlisted
    else -- if player meets none of the above conditions 
        player.TeamColor = "Visitors" -- set team to visitors
	   end
	end)

game:GetService("Players").PlayerAdded:Connect(function(Player)
    if Player:IsInGroup(4986262) then
        Player.TeamColor = BrickColor.new("Maroon")
    else
        Player.TeamColor = BrickColor.new("Parsley green")
    end
end)

6 comments

0

Use the lua code block so we can understand it, please.

0

Sorry, Fixed.

0

Why are there two Playeradded Events and why doesnt the first one have an end?

0

I had just mixed it together, Thats why there was 2, Would that break the script?

0

yes

0

Oh, Okay thanks how would I replace that?

1 answer

game.Players.PlayerAdded:connect(function(player)
	if player:GetRankInGroup(4980928) >= 238 then 
		player.Team = game.Teams["United States Marines"]
	elseif player:GetRankInGroup(4980928) < 238 then 
		player.Team = game.Teams["Basic Combat Training"]
	else 
		player.Team = game.Teams["Visitor"]
	end
end)

You can change it to an object value instead of a string value when changing the player.Team

1 comment

0

Also, you don't need to change the teamcolor.

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