I was testing with print lines and it would not print when I got to the if statement(line 5). I own the game pass but the code wont work. There are no errors in the output.
local newItem = game.ReplicatedStorage:FindFirstChild("InfBag"):Clone() capacityEvent = game.ReplicatedStorage:WaitForChild("UICapacityEvent") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() if game.MarketplaceService:PlayerOwnsAsset(player,11528871) then player.Character:FindFirstChild(player.BackpackItem.Value):Destroy() player.Character.Humanoid:AddAccessory(newItem) player.BackpackItem.Value = newItem.Name capacityEvent:FireClient(player, newItem.Capacity.Value) end end) end)
You need to use UserOwnsGamePassAsync
to detect when someone have a gamepass:
local newItem = game.ReplicatedStorage:FindFirstChild("InfBag"):Clone() capacityEvent = game.ReplicatedStorage:WaitForChild("UICapacityEvent") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() if game.MarketplaceService:UserOwnsGamePassAsync(player.UserId,11528871) then player.Character:FindFirstChild(player.BackpackItem.Value):Destroy() player.Character.Humanoid:AddAccessory(newItem) player.BackpackItem.Value = newItem.Name capacityEvent:FireClient(player, newItem.Capacity.Value) end end) end)