I’m trying to script the training game for my cafe group so that If your rank 5 (Trainee) and above you can join the game. The problem is people outside the group can join. I’ve tried looking on youtube but there’s nothing and nothing on the devforum I’ve seen so far. I’m not sure what I’m doing wrong so if I could have some help that’d be appreciated.
Can you show the code so we can see the problem?
You can use Player | Roblox Creator Documentation to check if the player rank is 5 or higher in the group.
I did my problem is people outside the group are joining
Then use Player | Roblox Creator Documentation if the player’s rank is not 5 or higher in the group.
local groupID = 10164635
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(10164635) == 5 or 6 or 7 or 8 or 9 or 10 or 11 or 12 or 13 or 14 or 15 or 16 or 17 or 18 or 19 or 20 or 21 or 22 or 23 or 24 or 25 or 26 or 27 or 28 then
else
plr:Kick("You are not ranked high enough")
end
end)
Heres the script
https://developer.roblox.com/en-us/api-reference/function/Player/GetRankInGroup
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if player:GetRankInGroup(id) < 5 then -- replace "id" with your group id
player:Kick("\nYour group role must be a Trainee or above to join,/ncome back later.")
-- kick the player if their rank id is under 5
end
end)
1 Like
You can use >= to check if the rank is 5 or higher.
Thanks so much it worked perfectly