How to make different group ranks get tools

So I would like to know how to make different group ranks get tools. Some ranks have the same tools. I tried multiple scripts but none of them worked. Anyone can help me please?

Use this when a player joins

Heres some example code

local groupid = --insert group id here

game.Players.PlayerAdded:Connect(function(player)
     local rank = player:GetRankInGroup(groupid)
     if rank == 255 then
     local tool = tool:Clone
     tool.Parent = player.Backpack
     end
end)

Okay but how to make them get a tool?

Probably something like this - in ServerScriptService

local groupID = 000 --your group id
local requiredRank = 00 -- the rank needed for the role
local toolLocation = game.Blah.Blah.Blah -- find the tool

game.Players.PlayerAdded:Connect(function(plr)
	local role = plr.GetRankInGroup(groupID)
	if role >= requiredRank then
		local tool = toolLocation:Clone()
		local toolCloneAgain = toolLocation:Clone()
		tool.Parent = plr.Backpack
		toolCloneAgain.Parent = plr.StarterGear
	end
end)

@Paul00990 Please also move this topic to #help-and-feedback:scripting-support

1 Like

Okay I moved it but I dont understand it

local toolLocation = game.Blah.Blah.Blah – find the tool

Just find (locate) the tool, for example,

game.ReplicatedStorage.Tools.Tool

So I just change this

game.ReplicatedStorage.Tools.Hello

Is your tool called ‘hello’ and is placed inside of ReplicatedStorage?

If so, then yes.

Put the tools into ServerStorage or ReplicatedStorage. Then, add a script into ServerScriptStorage and paste:

local tools = {
	game.ServerStorage.Tool1,
	game.ServerStorage.Tool2, 	--Defines the tools and makes it easier to do stuff. You can add more if you want to but you need a comma after every one up until the second to last one.
	game.ServerStorage.Tool3
	
}										

local grp = 00000 	--Replace 00000 with your group ID.

---

game.Players.PlayerAdded:Connect(function(plr)	--Connects a function when a player joins
	if plr:GetRankInGroup(grp) >= 000 then 	--Checks if they are above minumum rank
		plr.CharacterAdded:Connect(function()	--Connects a function when the player respawns/spawns
			local tool = tools[1]:Clone()	--Clones the tool and defines it
			tool.Parent = plr.Backpack	--Moves the tool into the player's backpack
		end)
	end
end)

You can copy and paste everything below “—” and change “000” and “tools[1]” (only change the number) to fit your needs.

This script doesn’t add the tool to the player’s StarterGear because the script clones a tool into the backpack everytime the player respawns/spawns.

If your tools are in ReplicatedStorage, then change “ServerStorage” to “ReplicatedStorage”

3 Likes

Just a heads up,

You should replace “GetRoleInGroup” with “GetRankInGroup.”
plr:GetRoleInGroup() returns a string and you can’t compare strings and numbers.

Oh yeah, my bad. I tend to get those 2 mixed up.

1 Like

@Paul00990 Did you manage to get it working?

Im testing it

1 Like

It is not working for some reason. The tool is in replicated storage
local groupID = 8347300 --your group id
local requiredRank = 255 – the rank needed for the role
local toolLocation = game.ReplicatedStorage.Tools.Detain – find the tool

game.Players.PlayerAdded:Connect(function(plr)
local role = plr:GetRoleInGroup(groupID)
if role >= requiredRank then
local tool = toolLocation:Clone()
local toolCloneAgain = toolLocation:Clone()
tool.Parent = plr.Backpack
toolCloneAgain.Parent = plr.StarterGear
end
end)

Change plr:GetRoleInGroup to plr:GetRankInGroup

local groupID = 8347300 --your group id
local requiredRank = 255 --the rank needed for the role
local toolLocation = game.ReplicatedStorage.Tools.Detain --find the tool

game.Players.PlayerAdded:Connect(function(plr)
	local role = plr:GetRankInGroup(groupID)
	if role >= requiredRank then
		local tool = toolLocation:Clone()
		local toolCloneAgain = toolLocation:Clone()
		tool.Parent = plr.Backpack
		toolCloneAgain.Parent = plr.StarterGear
	end
end) 

It still wont work

Let me do some testing real quick.

It worked perfectly fine for me, can you open the output window and tell me what it says?

17:06:05.305 - :microscope: Project Science [BETA] auto-recovery file was created

Community Leaderboard script loaded

17:06:06.013 - Tools is not a valid member of ReplicatedStorage “ReplicatedStorage”

17:06:06.014 - Stack Begin

17:06:06.014 - Script ‘ServerScriptService.Script’, Line 3

17:06:06.015 - Stack End

17:06:07.656 - Donation Board: Authorised - Loading Modules

17:06:07.657 - HTTP 403 (Forbidden)

17:06:07.657 - Stack Begin

17:06:07.657 - Script ‘Workspace.AdminTools’, Line 62

17:06:07.658 - Stack End

17:06:07.658 - :: Adonis :: Loading existing player: Paul00990

17:06:07.658 - 502: API Services rejected request with error. HTTP 403 (Forbidden)

17:06:07.659 - Stack Begin

17:06:07.659 - Script ‘Workspace.Boards.SettingsHandler’, Line 14

17:06:07.659 - Stack End

17:06:08.210 - Donation Board: ProcessReceipt Activated

17:06:09.935 - :: Adonis :: Loading Complete; Required by 0.31495003846204.Loader.Loader

17:06:11.016 - Infinite yield possible on ‘ReplicatedStorage.ACS_Engine.Eventos.Rappel:WaitForChild(“RopeEvent”)’

17:06:11.016 - Stack Begin

17:06:11.017 - Script ‘ServerScriptService.ACS_Server’, Line 1384

17:06:11.017 - Stack End

1111

ACS 1.7.5

17:06:13.563 - :: Adonis :: Beginning Adonis cleanup & shutdown process…

17:06:13.564 -

17:06:13.565 - -----------------------------------------------

17:06:13.565 - Adonis is already running! Aborting…

17:06:13.565 - Running Location: Workspace.Adonis_Loader.Loader.

17:06:13.566 - This Location: ServerScriptService.Adonis_Loader.Loader.

17:06:13.566 - -----------------------------------------------

17:06:13.567 - :: Adonis :: Unloading complete

17:06:19.157 - Disconnect from ::ffff:127.0.0.1|57660

Can you show me a screenshot of ReplicatedStorage?