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

How to use FindFirstChild to clone shirt?

So basically, I am trying to clone my shirt from the player's avatar onto my FPS arms. My first thought would be to try cloning, so here is the code for that. (The arms are in a folder called weapons inside of replicated Storage.)

local player = game:GetService("Players").LocalPlayer
local character = player.Character

local shirt = character:FindFirstChild("Shirt")
if shirt then
	local clone = shirt:Clone()
	clone.Parent = game.ReplicatedStorage.weapons.arms
end

I ran a check using FindFirstChild to see if the shirt existed, then, If the check was positive, I cloned the shirt and set the parent to the arms. When I play the game, I get no errors, but the shirt simply wasn't showing up. Anyone know a better aproach? Or a fix to my current code? Thanks.

1 answer

Use :FindFirstChildWhichIsA(), basically it finds a child that is the same "Class"(AKA you could search for a part, or humanoid, or a shirt in your case)

Example Code:

local character = player.Character

local shirt = character:FindFirstChildWhichIsA("Shirt")
if shirt then
    local clone = shirt:Clone()
    clone.Parent = game.ReplicatedStorage.weapons.arms
end

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