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

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

Asked by 4 years ago
Edited 4 years ago
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)
0
Use the lua code block so we can understand it, please. Dominus_ARA 24 — 4y
0
Sorry, Fixed. AureumMagnus 2 — 4y
0
Why are there two Playeradded Events and why doesnt the first one have an end? theking48989987 2147 — 4y
0
I had just mixed it together, Thats why there was 2, Would that break the script? AureumMagnus 2 — 4y
View all comments (2 more)
0
yes theking48989987 2147 — 4y
0
Oh, Okay thanks how would I replace that? AureumMagnus 2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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

0
Also, you don't need to change the teamcolor. Dominus_ARA 24 — 4y
Ad

Answer this question