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

Trouble with automatic team-assign spitting you into a Neutral team, what is going wrong?

Asked by 4 years ago

So, I'm trying to make a script that puts you on a team if you're at or above a certain rank in a group, and if you aren't in the group, puts you on a certain team. So far, it just spits you out onto a "Neutral" team no matter what I do I've playtested, there's no output issues, I've even tried inserting prints to see if those go through, but it just doesn't print, here is the code:

group1 = 4970180
wait(3)
local function onPlayerEntered(player)
local assigned = false
if player:IsInGroup(group1) and player:GetRankInGroup(group1) >= 11 then
    player.TeamColor = game.Teams:FindFirstChild("Prison Council").TeamColor
    local assigned = true

if player:IsInGroup(group1) and player:GetRankInGroup(group1) >= 5 then
    player.TeamColor = game.Teams:FindFirstChild("High Command").TeamColor
    local assigned = true

if player:IsInGroup(group1) and player:GetRankInGroup(group1) >= 2 then
    player.TeamColor = game.Teams:FindFirstChild("Correctional Staff").TeamColor
    local assigned = true

if player:IsInGroup(group1) and player:GetRankInGroup(group1) == 1 then
    player.TeamColor = game.Teams:FindFirstChild("Inmate").TeamColor
    local assigned = true

else
    player.TeamColor = game.Teams:FindFirstChild("Inmate").TeamColor
    local assigned = true
end 
    local assigned = false
end
end
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

0
Neutral is usually given if the player is put into a team that doesn't exist. Does your FindFirstChild return nil, as in it cannot find the team? alphawolvess 1784 — 4y

Answer this question