What this does, is if I touch the brick, it will clone my StarterGear and paste it into my backpack. The error I am getting is: Workspace.Weapon Taker.Script.Remove:5:Attempt to call method ('Clone' a nil value)
Here is my code:
function onTouch(obj) if obj.Parent:findFirstChild("Humanoid")~=nil then p=game.Players:findFirstChild(obj.Parent.Name) if p~=nil and p.Chakra.Value == "none" then ch=p.Backpack:getChildren():Clone() ch.Parent = p.Backpack p.Chakra.Value = good elseif p.Chakra.Value == "good" then print("good") end end end script.Parent.Touched:connect(onTouch)
ch=p.Backpack:getChildren():Clone()
GetChildren returns a table of all the children of Backpack, and you can't call Clone() on a table. You can call it on each item in a table though.
ch=p.Backpack:getChildren() for _,child in pairs(ch) do local clone = child:Clone() clone.Parent = p.Backpack clone.Chakra.Value = good end