I have recently come into a scripting obstacle that requires the use of the clone feature, and I am wondering a few things. I apologize for the lack of script here, but I don't really know what to write beyond sticking :clone at the end of the object you want to clone when calling it in a script.
First off, how do you specify where to clone something to and will it override anything with an identical name?
Secondly, if it does not override an object with an identical name then how do you make it do so?
I am also having trouble accessing player's limbs. for example:
game.Players.LocalPlayer.Head
will return with: Head is not a valid member of Player. Any idea how to get into those precious parts?
Alright. So, clone clones an object. When you call clone() by itself, it basically parents the new instance as nil. It does NOT replace any current objects, unless you delete the old one!
Example:
game.Workspace.Part:clone().Parent = game.Workspace -- This will clone "Part", and parent it to workspace. It has the same name!
local part = game.Workspace.Part:clone() game.Workspace.Part:Destroy() part.Parent = game.Workspace -- The above script REPLACES the current part, with a cloned one!
And, for a character's head, when using a LocalScript and LocalPlayer, you have to specif ".Character"
Ex: Local Script
game.Players.LocalPlayer.Character.Head.BrickColor = BrickColor.new("Bright red")