Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to make items for group members only?

So im creating this simulator and i want to add a backpack/storage that is only obtainable by group members. The script im using however only works with tools. The backpack storage thing i want is an accessory and i wanted to know how i can modify this script to make it usable like that. Thanks

local groupId = 2783101

local tool = game.ServerStorage.TurtleShellBackpack
 
function onPlayerSpawned(player)
  if player:IsInGroup(groupId) then
    tool:Clone().Parent = player.Backpack
  end
end
 
game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

1 answer

✓ Accepted answer

Try:

local groupId = 2783101

local tool = game.ServerStorage.TurtleShellBackpack

function onPlayerSpawned(player)
	if player:IsInGroup(groupId) then
		tool:Clone().Parent = player.Character -- changed from player.Backpack
	end
end

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function()
		onPlayerSpawned(player)
	end)
end)

This will ensure it goes on the character

5 comments

0

It worked thank you

0

If you accept it you can 1. Support my rep 2. Support your rep 3. Make it so that my answer stands out. Please do it

0

Since your question has been answered, you can accept this answer and move on. You have not yet, and therefore you do not earn anything.

1

this is sad but I got you, 3 upvotes, nice answer, I will probably use it in the future, I will accept it for you.

0

I upvoted too!

This discussion is preserved as it was. New answers, comments, and votes are closed.