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

Player Morph Not working?

Asked by 8 years ago

The goal is to change the characters body, to the body parts inside the scripts, I get no errors, but the problem is the hats are being removed and the torso is not changing. Code:

local plr = game.Players.LocalPlayer
local char = plr.Character
        BodyParts = char:GetChildren()
        for i,b in pairs(BodyParts) do
            if (b.className == "") or (b.className == "CharacterMesh") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
                b:Remove()
            end
            if (b.className == "Part") then
                if (b.Name == "Torso") then
                    if (b:findFirstChild("roblox") ~= nil) then
                        b.roblox:Remove()
                    elseif (b:findFirstChild("Decal") ~= nil) then
                        b.Decal:Remove()
                    end
                end
                if (b.Name == "Head") then
                    if (b:findFirstChild("Mesh") ~= nil) then
                        b.Mesh:Remove()
                    end
                end
            end
            wait(0.1)
        end

        BodyParts = script.Parent.Body:GetChildren()
        for i,b in pairs(BodyParts) do
            if (b.className == "CharacterMesh") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
                b:Clone().Parent = char
            end
            if (b.className == "BodyColors") and (char:findFirstChild("Body Colors") ~= nil) then
                char.Parent:findFirstChild("Body Colors").HeadColor= b.HeadColor
                char.Parent:findFirstChild("Body Colors").LeftArmColor= b.LeftArmColor
                char.Parent:findFirstChild("Body Colors").LeftLegColor= b.LeftLegColor
                char.Parent:findFirstChild("Body Colors").RightArmColor= b.RightArmColor
                char.Parent:findFirstChild("Body Colors").RightLegColor= b.RightLegColor
                char:findFirstChild("Body Colors").TorsoColor= b.TorsoColor
            end
            if (b.className == "Part") then
                if (b.Name == "Torso") then
                    if (b:findFirstChild("roblox") ~= nil) then
                        b.roblox:Clone().Parent = char.Torso
                    elseif (script.Parent.Body.Torso:findFirstChild("Decal") ~= nil) then
                        b.Decal:Clone().Parent = char.Torso
                    end
                end
                if (b.Name == "Head") then
                    if (b:findFirstChild("face") ~= nil) then
                        hit.Parent.Head.face.Texture = b.face.Texture
                    elseif (script.Parent.Body.Head:findFirstChild("Decal") ~= nil) then
                        hit.Parent.Head.face.Texture = b.Decal.Texture
                    end
                    if (b:findFirstChild("Mesh") ~= nil) then
                        b.Mesh:Clone().Parent = char.Head
                    end
                end
            end
            if (b.className == "") then
                local h = Instance.new("")
                h.Name = b.Name
                h.AttachmentPos = b.AttachmentPos
                b.Handle:Clone().Parent = h
                h.Parent = char
            end
            wait(0.1)
        end

Answer this question