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

I need help with changing Teams please?

Asked by
Validark 1580 Snack Break Moderation Voter
10 years ago

What I want: When a player joins a game, it will check their rank, then either make them a trainer, or a trainee.

Currently, I have the following inside a GUI. What it does is check if they are the right rank, then remove it if they are not.

nameA = {"TheExtinction"} plr = script.Parent.Parent.Parent

for i = 1, #nameA do if plr:GetRankInGroup(groupid)>=152 or plr.Name == nameA[i] then plr.TeamColor = BrickColor.new("Magenta") else plr.TeamColor = BrickColor.new("Lime green") wait(.01)
script.Parent:remove()

end end

note the groupid is identified earlier in the script

What is wrong with this? The removing works but the team changing doesn't.

0
Code block please....... kudorey619 138 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

I was not able to figure out what you were trying to do with the script above. I think I have written what you are looking for, this script basically, when someone joins, it checks their groups to see if they are in the group you want, and then their rank. Make sure you change the "IDhere" on line 1 to be the group ID. Just the numbers, no quotes or anything after the " = " This script will just need to be a normal script inside of workspace. Name it anything that you want to name it. This script should be good to go.

local groupId = IDhere --Replace "IDhere" with the group ID
local rank = 52 


function check(plr) --plr will be the new player
    if plr:IsInGroup(groupID) and plr:GetRankInGroup(groupID) >= rank then --checks if in group, and their rank
        plr.TeamColor = BrickColor.new("Magenta") --If they are HR
        plr:LoadCharacter() --Spawns them
    else 
        plr.TeamColor = BrickColor.new("Lime green") --If they are not an HR
        plr:LoadCharacter() --Spawns them
    end
end

game.Players.PlayerAdded:connect(check) --Runs the function when someone joins.

Ad

Answer this question