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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
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)
0
This works EricStoynov1749 -5 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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
0
Hey thanks, but for some reason, I always get ranked the recruit team. But I am 253 in the group. EricStoynov1749 -5 — 4y
0
Have you tried a print statement to check if it properly checking your rank? jediplocoon 877 — 4y
0
Ok Ill try that. EricStoynov1749 -5 — 4y
0
Jedi, its not printing at all, This is what I did to the script.https://pastebin.com/raw/Z7rqg684 EricStoynov1749 -5 — 4y
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 jediplocoon 877 — 4y
Log in to vote
0
Answered by 4 years ago

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
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. EricStoynov1749 -5 — 4y

Answer this question