Server Lock Script for Groups!

Use this Script if you want only customers and staff in your game.

by Ginoskoida

Author Avatar

Interview Center Server Lock Script Tutorial.

Hey there! My name is Ginoskoida, and I'll be going over how to make a group rank range only game script!

This script is best used for interview centers, if you want only people that are ranked "Customers" or something and they want an interview, they are allowed in the game. Otherwise if they are in the between ranks "Trainee" and "Head Chef" then they aren't allowed in the interview center because they have already done their interview.

-------------------------Variables--------------------------

Ok, so the first thing we need to get is the group ID of your group. To find the group ID, go over to your browser and open up your group home page. Then you should look at the think and find some numbers in it that look like this:

https://www.roblox.com/groups/5265927/Briss

The bolded numbers is your group ID, you should copy the numbers without anything else.

Ok, so once you have copied the numbers a.k.a, you're group ID, you should go back to Roblox Studio and make a variable with the group ID in it. Type in the following:

local groupID = 5265927

That's it for that, now you need get your rank IDs. To get them, go back to your group home page and open up the group configuration page. Once you're in it, go to the roles tab and click on the role that you want to set as your minimum rank allowed in the game. When you get it, look for something that says Rank (0-255). Copy the number that is below the "Rank (0-255)" in the text box and go back to Roblox studio and type in this:

local minRank = 1 ---Replace the 0 with the copied rank.

After you've done that, you need the max rank ID. Go backc to your group configuration page and click on the role you want as your maximum rank allowed in-game. Do the same thing as the minimum rank before and type in the following:

local maxRank = 3 ---Replace the 0 with the copied rank.

Now that's all we need to do for this. We are now going to go on the harder bit now.

----------------------------SCRIPT-------------------------

We need to make it so when a player joins the game, the game will check if the player is in the rank range allowed in-game. We need to do the following:

game:GetService("Players").PlayerAdded:connect(function(plr)

end)

That's where we are going to put all of our main code inside, the code starts of with the game telling us that a player has joined the game. We need to make it so it checks whether the player is in the allowed group rank range or not. To do this, we need to do the following:

game:GetService("Players").PlayerAdded:connect(function(plr)
    if plr:getRankInGroup(groupID) >= minRank and plr:getRankInGroup(groupID) < maxRank then
        plr:Kick("Sorry, you're not allowed in here.") ---Put your kick message in here.
    end
end)

That means if the players rank in the group is higher than or equals to the minimum rank and if they are lower than or equals to the maximum rank, the game will kick them because they have already done their interview.

Overall this is the code that you should have:

local groupID = 5265927
local minRank = 0
local maxRank = 1

game:GetService("Players").PlayerAdded:connect(function(plr)
    if plr:getRankInGroup(groupID) >= minRank and plr:getRankInGroup(groupID) <= maxRank then
        plr:Kick("Sorry, you've already done your interviews.")
    end
end)

That's all you need to do! Make sure you put in the correct group ID or else the script will not work.

Thanks for reading this! Hopefully you learnt something today from this tutorial! -Ginoskoida

View in-game to comment, award, and more!