I'm trying to make it so that whatever rank you are in the group you get certain items and it's not doing that could someone help me with the script please this is what I have.

game.Players.PlayerAdded:connect(function(player) -- get the player
	local name = player.Name -- name of the player
	print(name) -- just a test
	local groupID = 3751720

			
		if player:IsInGroup(groupID) then -- checking if player is admin
		     if player:GetRankInGroup(groupID) == 1 then	
		        
	            local gun = game.ReplicatedStorage["Flashlight"]:Clone()
				gun.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gunS = game.ReplicatedStorage["Radio"]:Clone()
				gunS.Parent = game.Players[name]:WaitForChild("Backpack")
	
				-----------------------------------------------------------
               elseif player:IsInGroup(groupID) then
               if player:GetRankInGroup(groupID) == 2 then	
		        
	            local gun = game.ReplicatedStorage["Flashlight"]:Clone()
				gun.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gunS = game.ReplicatedStorage["Radio"]:Clone()
				gunS.Parent = game.Players[name]:WaitForChild("Backpack")
				
		
				-----------------------------------------------------------
				
				elseif player:IsInGroup(groupID) then -- checking if player is admin
		        if player:GetRankInGroup(groupID) == 3 then	
		        
	            local gun = game.ReplicatedStorage["Flashlight"]:Clone()
				gun.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gunS = game.ReplicatedStorage["Radio"]:Clone()
				gunS.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun3 = game.ReplicatedStorage["Baton"]:Clone()
				gun3.Parent = game.Players[name]:WaitForChild("Backpack")
				
				---------------------------------------------------------
				
				elseif player:IsInGroup(groupID) then -- checking if player is admin
		        if player:GetRankInGroup(groupID) == 4 then	
		        
	            local gun = game.ReplicatedStorage["Flashlight"]:Clone()
				gun.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gunS = game.ReplicatedStorage["Radio"]:Clone()
				gunS.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun3 = game.ReplicatedStorage["Baton"]:Clone()
				gun3.Parent = game.Players[name]:WaitForChild("Backpack")
				
				---------------------------------------------------------
				
				elseif player:IsInGroup(groupID) then -- checking if player is admin
		        if player:GetRankInGroup(groupID) == 5 then	
		        
	            local gun = game.ReplicatedStorage["Flashlight"]:Clone()
				gun.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gunS = game.ReplicatedStorage["Radio"]:Clone()
				gunS.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun3 = game.ReplicatedStorage["Baton"]:Clone()
				gun3.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun4 = game.ReplicatedStorage["PepperSpray"]:Clone()
				gun4.Parent = game.Players[name]:WaitForChild("Backpack")
				
				elseif player:IsInGroup(groupID) then -- checking if player is admin
		        if player:GetRankInGroup(groupID) == 6 then	
		        
	            local gun = game.ReplicatedStorage["Flashlight"]:Clone()
				gun.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gunS = game.ReplicatedStorage["Radio"]:Clone()
				gunS.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun3 = game.ReplicatedStorage["Baton"]:Clone()
				gun3.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun4 = game.ReplicatedStorage["PepperSpray"]:Clone()
				gun4.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun5 = game.ReplicatedStorage["ER-31X"]:Clone()
				gun5.Parent = game.Players[name]:WaitForChild("Backpack")
				
				elseif player:IsInGroup(groupID) then -- checking if player is admin
		        if player:GetRankInGroup(groupID) == 11 then	
		        
	            local gun = game.ReplicatedStorage["Flashlight"]:Clone()
				gun.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gunS = game.ReplicatedStorage["Radio"]:Clone()
				gunS.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun3 = game.ReplicatedStorage["Baton"]:Clone()
				gun3.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun4 = game.ReplicatedStorage["PepperSpray"]:Clone()
				gun4.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun5 = game.ReplicatedStorage["ER-31X"]:Clone()
				gun5.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun6 = game.ReplicatedStorage["GLOCK"]:Clone()
				gun6.Parent = game.Players[name]:WaitForChild("Backpack")
				
				local gun7 = game.ReplicatedStorage["Handcuffs"]:Clone()
				gun7.Parent = game.Players[name]:WaitForChild("Backpack")
											
											
		end
		end
		end
		end
		
		``

2 comments

0

You don't need to use IsInGroup. GetRankInGroup returns 0 if they're not in. Why do you check it every single if statement though

0

Try putting the tool in the Player's Character instead and if that doesn't work then feel free to message me on ROBLOX, and I will then take a good look at the script.