I want to clone a Accessory but it doesn't work...
Script :
Player.Character[Accessory]:Clone()
If you want to clone Instances by searching their Classname this might be tricky, but using a For Loop it's easy!
First we need to search through the character and get all of it's items.
local Character = Player.Character:GetChildren() -- a table with all the children for _, object in pairs(Character) -- we get all objects from the table (we get all the children) _ means blank print(object.Name) -- prints out their name end
We also need to ensure that the object is an Accessory. Then we're gonna clone it! Remember, always parent the clones after cloning objects!
local Character = Player.Character:GetChildren() -- a table with all the children for _, object in pairs(Character) -- we get all objects from the table (we get all the children) _ means blank if object:IsA("Accessory") then -- check if the object is an accessory local clone = object:Clone() clone.Parent = workspace -- puts the hat in workspace end end
Note that the script clones all accessories.
And now we are done!
local accessory = Player.Character[Accessory] accessory:Clone().Parent = accessory.Parent
Closed as Non-Descriptive by User#5423, Programical, Vulkarin, and cabbler
This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.
Why was this question closed?