Group rank tool

Sorry if the name sounds off. I could not think of a correct name for it. I want to make a script that if you are a certain rank and above you get a certain tool. If you are below you don’t get it. How do I make that? I have searched for multiple youtube videos. Thanks!

Note: I am NOT asking for a script. I simply want something that will help me (ex: youtube video). Thanks for reading btw! :smiley:

5 Likes

yes

Well you need to get the group Id and then the rank that you want and it’s ID, then you can do an if statement like this

local groupId = groupIdHere
local rankNeeded = rankIdHere

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(groupId) >= rankNeeded then
        -- give the tool
    else
        return
    end
end)

This is just a script that can get you started on it, you can improve it and use it to fit your needs.

1 Like

Just to make sure, this is a script in ServerScriptService, right?

Yes.

( 30 charssssssssssssssssss )

This is my script so far.

local tool = game.ReplicatedStorage.FoodStorage.PremiumMenu
local groupID = 4796549
local rankneeded = 12

local debounce = false

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInHroup(groupID) >= rankneeded then
	local tool = tool:Clone()
	tool.Parent = Player.Backpack
	else
		return
    end
end)

Is this good?

Try it out, let me know if it works.

edit:

local tool = game.ReplicatedStorage.FoodStorage.PremiumMenu
local groupID = 4796549
local rankneeded = 12

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(groupID) >= rankneeded then
        local tool = tool:Clone()
	tool.Parent = Player.Backpack
    else
        return
    end
end)
3 Likes

Thank you so much!!!

I would probably change the variable name, ‘tool’, inside the function to something like, ‘toolClone’.

The variable name ‘tool’ shows up twice and it can get confusing in larger scripts. Also, sometimes the script won’t know which variable you’re referring to.

That’s true. @romeanyguy10 it’s best if you change “tool” into another name for the variable.

It still worked so………………………………

When a user resets their character, the tool won’t load so I’d suggest using Player | Roblox Creator Documentation.

Edit: Here’s the re-written script:

local tool = game.ReplicatedStorage.FoodStorage.PremiumMenu
local groupID = 4796549
local rankneeded = 12

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		if player:GetRankInGroup(groupID) >= rankneeded then
			local toolClone = tool:Clone()
			toolClone.Parent = player.Backpack
		else
			return
		end
	end)
end)

Or you could just add it to their StarterGear.

1 Like

They want the tool to be given to staff members.

1 Like

What does this have to do with giving it to non-staff members? StarterGear isn’t the same as StarterPack. When you put a tool in StarterGear, it gives them the tool everytime they respawn.