Hi everyone, so, i was making a script for a gui. So I wanted to do this, when you buy the item, it clones from the replicated storage to the player’s backpack, but when I press the Buy button in my gui, the output says: "… :9: attempt to index nil with “clone”. Can anybody help me to fix this?? I would really appreciate
The tools are in a folder called “Tools” in Replicated Storage, and i already made a variable for the tools that are in that folder, let me send u a pic:
Firstly, you should add the tools in server side with a remote event. Also, may I see ItemName’s value property, and its descendants? Your script doesn’t seem to contain any typos or scripting errors.
Try adding prints in your script to detect the error. For example:
for i,v in pairs (game.ReplicatedStorage:WaitForChild("Tools"):GetChildren()) do
print(v.Name)
end
if tool then
print("tool exists")
elseif tool == nil then
print("tool does not exist")
end
print(script.Parent.Parent.ItemName.Value)
for i,v in pairs (game.ReplicatedStorage:WaitForChild("Tools"):GetChildren()) do
print(v.Name)
if script.Parent.Parent.ItemName.Value == v.Name then
print("tool found on first loop")
end
end