So I am making something which restricts players for joining apart from a player in a group with a certain role. I tried doing this:
local Roles = { 255; 253; 252; 251; 248; } game.Players.PlayerAdded:Connect(function(Player) for i,v in ipairs(Roles) do if (Player:GetRankInGroup(-GROUPID-)) == v then -- Limits who joins print("Allow") else Player:Kick("Not allowed to join") -- Change kick message end end end)
Now it does work, however if you are one of the ranks, then your not the other ranks so then you get kicked for not being those ranks. How would I fix this?
Typing out what I said in the comment, I know its clunky and messy and theres a better way to do it so don't @ me.
local Roles = { 255; 253; 252; 251; 248; } game.Players.PlayerAdded:Connect(function(Player) if (Player:GetRankInGroup(-GROUPID-)) == Roles[1] or (Player:GetRankInGroup(-GROUPID-)) == Roles[2] or (Player:GetRankInGroup(-GROUPID-)) == Roles[3] or (Player:GetRankInGroup(-GROUPID-)) == Roles[4] or (Player:GetRankInGroup(-GROUPID-)) == Roles[5] then -- super gross code ewww print("Allow") else Player:Kick("Not allowed to join") -- Change kick message end end)