Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you clone a brick into a player?

I am currently working on morph script that copies parts a humanoid in replicatedstorage and clones them into your character. However when I try to clone a brick it just sticks it becomes a separate entity inside of the player rather than being attached to said player.

the script i currently have is here, with line 12 being the problem

local player = game.Players.LocalPlayer
local cactus = game.ReplicatedStorage.brawler.cactusg


function onClicked()
player.Character.Head.face.Texture = cactus.Head.Decal.Texture
cactus.Shirt:clone().Parent = player.Character
cactus.Pants:clone().Parent = player.Character
player.Character["Left Arm"].BrickColor = BrickColor.new("Camo")
player.Character["Right Arm"].BrickColor = BrickColor.new("Camo")
player.Character["Torso"].BrickColor = BrickColor.new("Camo")
cactus.Head:clone().Parent = player.Character.Head
end

script.Parent.MouseButton1Click:connect(onClicked)

I have tried cloning cactus.Head into a bunch of different place into the player to no avail, and have run out of ideas.

2 answers

✓ Accepted answer

So you've successfully gotten the cactus in the Character right? If that's the case you just have to stick it to the head with a weld.

Simple weld with a bit to help the cactus sticking:

cactushead = cactus.Head:Clone()
cactushead.Parent = player.Character
W = Instance.new("Weld",player.Character.Head)
W.Part0 = W.Parent
W.Part1 = cactushead

And I wouldn't recommend putting parts in parts, don't let me stop you from your dreams though.

EDIT: Here's a link to Welds to further your understanding of these incredibly useful and beautifully simple joints.

4 comments

0

Beautiful, apologize for not getting to this sooner.

0

Still one problem. while cactus.Head attaches perfectly, it's children will still fall to the floor despite my attempts to try and expand the script to clone them as separate from the head with their own new welds

0

So you're trying to weld a model of sorts to the Head? Like a hat? I would weld each part of the hat model to eachother first, and use cactus.head as a basepart to then weld to the character's head. I don't put parts within parts in a hierarchy because joints (in this case, welds) fail to function properly. If the right-click -> insert-object prompt doesn't-

0

-list the object (part in a part), it's best not to force it.

local player = game.Players.LocalPlayer
local cactus = game.ReplicatedStorage.brawler.cactusg


function onClicked()
player.Character.Head.face.Texture = cactus.Head.Decal.Texture
cactus.Shirt:clone().Parent = player.Character
cactus.Pants:clone().Parent = player.Character
player.Character["Left Arm"].BrickColor = BrickColor.new("Camo")
player.Character["Right Arm"].BrickColor = BrickColor.new("Camo")
player.Character["Torso"].BrickColor = BrickColor.new("Camo")
cactus.Head:clone().Parent = player.Character.Head
end

script.Parent.MouseButton1Click:connect(onClicked)

the code is fine. if i am correct the problem is not with the code it is with the type of script you are using.

local player = game.Players.LocalPlayer
         -- local player is used when you are using a localscript.

if you are not using a local script then use that for this code

2 comments

0

The script works just fine apart from the above mentioned cloned cactus.Head part not being physically attached to the player but rather being inside the player as a separate entity.

0

oh sorry i didnt read all of it.

This discussion is preserved as it was. New answers, comments, and votes are closed.