Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you properly use the 'clone' and how do you access player's body parts?

Asked by
Smunkey 95
8 years ago

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?

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

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") 
0
Awesome, thanks! Smunkey 95 — 8y
Ad

Answer this question