the pistol3 is next why ? (It's for a unlock the next item to buy)
This is a video with the bug https://www.youtube.com/watch?v=bCXXtnPLcVI
local Player = game.Players.LocalPlayer
local ReplicatedStorage = game.ReplicatedStorage
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.PetInventory.Visible == false then
script.Parent.Parent.PetInventory.Visible = true
local inventory = script.Parent.Parent.PetInventory.Inventory.InventoryFrame
local plritem = Player:FindFirstChild("Items"):GetChildren()
local itemfolder = ReplicatedStorage:FindFirstChild("Items"):GetChildren()
for i = 1,#plritem do
for j = 1,#itemfolder do
if plritem[i].Name == itemfolder[j].Name then
print(plritem[i].Name, itemfolder[j+1].Name)
local item = inventory:FindFirstChild(itemfolder[j+1].Name)
item.Background.Locked.Visible = false
end
end
end
else
script.Parent.Parent.PetInventory.Visible = false
end
end)
19:29:19.471 - Players.xDZweird.PlayerGui.Shop.PetInventoryButton.LocalScript:16: attempt to index nil with 'Name' 19:29:19.472 - Stack Begin 19:29:19.472 - Script 'Players.xDZweird.PlayerGui.Shop.PetInventoryButton.LocalScript', Line 16 19:29:19.473 - Stack End Pistol Pistol2 Pistol2 Pistol3 Pistol4 Pistol5 Pistol5 Pistol6

3 comments
It would seem itemfolder[j+1] is nil. You're looping as many times as there are items in the table itemfolder. Therefore on the last iteration, itemfolder[j] would be the last thing in the table, yet you try to index it with j+1 which does not exist.
Thank you for your answer, so how to buy an item you have to buy the previous one
https://youtu.be/HauHo6UQLVw