Here is my cloning script:
game.ServerStorage.Cardone:Clone().Parent = script.Parent.Parent
How do I change the name of the item I'm cloning in its new spot
Here is my cloning script:
game.ServerStorage.Cardone:Clone().Parent = script.Parent.Parent
How do I change the name of the item I'm cloning in its new spot
Well, one way is just by saying
script.Parent.Parent.Cardone
But, that may not be as easy as it seems, as some people clone an object multiple times. You would set a variable for the clone, so
clone = game.ServerStorage.Cardone:clone()
clone.Parent = script.Parent.Parent
clone.Name = "Hi"
Simple, heres how;
local Cardone = game:WaitForChild("ServerStorage"):WaitForChild("Cardone"):Clone() --This will repeat waiting until 'ServerStorage' has loaded, and 'Cardone' has loaded into 'ServerStorage', and when loaded, will set the 'Clone' method of 'Cardone'; The 'Clone' method clones a instance, like a copy of something
Cardone.Parent = script.Parent.Parent --This will set 'Cardone''s Parent
Cardone.Name = "Cardone" --This will set the name of the Cloned 'Cardone'
Hope this helped!
Or, you could try out my custom cloning function that allows you to set properties much easier.
function cloneWithProperties(obj)
if not(type(obj)=='userdata') then return end;
local newi = obj:Clone();
return function(props)
if not(type(props)=='table') then return end;
for i,v in pairs(props) do
newi[i] = v;
end;
end;
end;
cloneWithProperties(game.Workspace.Part){Parent = game.Workspace.Model; Name = 'kClone testing';};
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
This works, thanks!
Glad I could help!
While this would surely work, it'd be a great idea to look into scopes. Is 'clone' a global variable? A local variable? Depends on where this code runs.