Hello, I’m trying to make a script that assorts players with a specific group rank to a specific team in-game. It doesn’t seem to work. Got any ideas? Script is below.
I’m not the best so try not to judge me.
local COS = game.Teams.COS
game:GetService(“Players”).PlayerAdded:Connect(function(plr)
if plr:IsInGroup(9882533) then
if plr:GetRankInGroup(9882533) == 255 and 254 and 100 then
plr.Team = COS
end
end end)
It’s because of the way you did the if statement, you’re not doing an assignment on 254
and 100
, so those will be truthy, meaning it’ll see
if plr:GetRankInGroup(9882533) == 255 and true and true then
If you are not the owner of the group, it will never give you the table evne if your rank is 254 or 100. Also it still wouldn’t give you it even with a fix since you can’t be 3 ranks at once, think you meant or
in this case
Just use a table
local COS = game:GetService("Teams").COS
local allowedRanks = {255, 254, 100}
game:GetService("Players").PlayerAdded:Connect(function(plr)
if table.find(allowedRanks, plr:GetRankInGroup(9882533)) then
plr.Team = COS
end
end)
If you have more teams you want this to apply to, make a dictionary with the key being the team object and value being a table of ranks, then just loop through the dictionary
3 Likes
Thanks! I was assuming that the if statement I created was correct but realised my mistake.
1 Like