Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how to make items for group members only?

Asked by 3 years ago

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

Log in to vote
6
Answered by 3 years ago

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

0
It worked thank you coolflamingoiscool 9 — 3y
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 User#30567 0 — 3y
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. iiDkOffical 109 — 3y
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. greatneil80 2647 — 3y
0
I upvoted too! iivSnooxy 248 — 3y
Ad

Answer this question