When i buy a certain item with this script from a simulator-like shop, it gives me the error Attempt to index a nil value.
game.ReplicatedStorage.ShopBuy.OnServerEvent:Connect(function(player,page)
local tool = game.ReplicatedStorage:WaitForChild("Tools")
local shop = game.Workspace.Shop
local clone = tool:FindFirstChild(shop:FindFirstChild("Part"..page).ItemName.Value):Clone() -- Breaks here
local clone2 = tool:FindFirstChild(shop:FindFirstChild("Part"..page).ItemName.Value):Clone()
clone.Parent = player.Backpack
clone2.Parent = player.StarterGear -- So that the player won't lose the tool even if they died.
end)

4 comments
you're looking for the shop in replicatedstorage, but we already know its in workspace..
The items are in the replicated storage, this script makes it so when the button is clicked, it adds the item to the players inventory, saves it there. The script is looking for the items in the replicated storage to add to the players backpack.
Attempt to index a nil valuemeans either your code can't find it or it does not even exist.Thanks for telling me that, im gonna go try to fix it thanks.