Clone Tool Problem

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

Thx

2 Likes

it means that the item you are trying to clone does not exist, try checking the tool’s localization.

1 Like

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:

may I see the whole script? You might also have moved the tool’s localization through a script. Also check if ItemName.Value is spelled correctly

sure, ill send u 2 pics, one of the explorer and of the script:

and

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.

Okay, may i show you the error? image

the error is because the script could not find a tool with the same name as ItemName.Value.

let me check all the itemName values, maybe i made a mistake there

The error is telling you that the tool hasn’t been found

all the items names are right, the name matches with the ones in the Replicated Storage, ill post the ItemName descendant: image and the script in it image

its weird because the error appears when i do it with all the tools, its not just only one

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

This is to check if the items exist

1 Like

It says that the tool does not exist

add this too:

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

1 Like

I think I found the issue. the script says that script.Parent.Parent.ItemName.Value is empty, check if it has a value.

1 Like

Yeah, indeed, the ItemName has no value actually

image