Help with group rank only gears

Hi! I’m making a game and I want to create a script that gives a rocket launcher gear to people that have a high enough rank in a group.

My goal is to give people with ranks higher than 253 a rocket launcher, which would be stored in ServerStorage and would be transferred to the players’ backpack.

The script is a normal script located in the Workspace.

Here’s the script I wrote:

game.Players.PlayerAdded:Connect(function(plr)

if plr:GetRankInGroup(GroupIDHere) > 253 then
	game.ServerStorage.RocketLauncher.Parent = plr.Backpack
end
end)

I put “GroupIDHere” as a placeholder for a group ID.

I’ve tried looking everywhere and using some other posts I found on the Devforum to help, but I couldn’t find a good solution.

Can someone help? Thanks!

1 Like

Hey there!

I believe the issue you’re having is that you’re trying to make "RocketLauncher"s parent equal to the player’s backpack. Good in theory, but when a whole line of code, like game.ServerStorage.RocketLauncher.Parent, is written out, it refers to one object. In this case, you tell the script to navigate to the RocketLauncher’s parent (which is ServerStorage).

Try this:

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(GroupIDHere) > 253 then
		local clone = game.ServerStorage.RocketLauncher:Clone()
		clone.Parent = plr.Backpack
	end
end)

This makes a copy of the rocket launcher and makes it part of the player’s backpack.

Additionally, if you want it to give them a rocker launcher every time that player spawns, use this code:

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(GroupIDHere) > 253 then
		plr.CharacterAdded:Connect(function(char)
			local clone = game.ServerStorage.RocketLauncher:Clone()
			clone.Parent = plr.Backpack
		end)
	end
end)

This makes it so that each time a new character of that player is added, they get the rocket launcher.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.