Im making a simulator and i want to make a backpack that only people who join my group can buy. But this script im using directly puts it on the player. I want it so players have to buy it in the shop but only people in the group can buy it. Does anyone know how i can do this?

local groupId = 3123903

local backpack = game.ServerStorage.GroupBackpack
 
function onPlayerSpawned(player)
  if player:IsInGroup(groupId) then
    backpack:Clone().Parent = player.Character
  end
end
 
game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

2 comments

0

use Connect instead of connect, the latter one has been deprecated and use GetService for the services

0

Make a shop, use the :IsInGroup() boolean as a debounce.