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

Baby fake torso not welding to real torso?

Asked by 7 years ago

Hi.

I'm trying to copy off an old baby morph script (don't judge me). I did it, but for some reason, the fake torso is not welding to the real torso (I think).

Can someone please tell me what I missed?

My script:

storage = game:GetService("ReplicatedStorage")

storage.Events.PlayerToBaby.OnServerEvent:connect(function(player)
    print("Request received.")
    local char = player.Character -- Get character
    -- Head mesh size
    local mesh = char.Head:FindFirstChild("Mesh")
    if mesh then
        mesh.Scale = Vector3.new(1, 1, 1)
    end
    -- Torso management
    local torso = char.Torso
    torso.Transparency = 1
    torso.CanCollide = false
    -- Existing FakeTorso destruction
    local fakeTorso = char:FindFirstChild("FakeTorso")
    if fakeTorso then
        fakeTorso:Destroy()
    end
    -- New FakeTorso
    local body = Instance.new("Part", char)
    body.BrickColor = BrickColor.new(1)
    body.Position = torso.Position
    body.Name = "FakeTorso"
    body.FormFactor = Enum.FormFactor.Symmetric
    body.Size = Vector3.new(1, 1, 1)
    -- Welds
    local weld1 = Instance.new("Weld", torso)
    weld1.Part0 = weld1.Parent
    weld1.Part1 = char.Head
    weld1.C1 = CFrame.new(0, 0.25, 0)
    local weld2 = Instance.new("Weld", torso)
    weld2.Part0 = weld1.Parent
    weld2.Part1 = char.Head
    weld2.C1 = CFrame.new(0, -0.8, 0)
    -- FakeTorso mesh
    local bodyMesh = Instance.new("SpecialMesh", body)
    bodyMesh.Scale = Vector3.new(1.2, 1.5, 1.2)
    -- Remove legs and make arms invisible (so the baby can hold tools)
    for _, each in ipairs(char:GetChildren()) do
        if each:IsA("BasePart") and each.Size == Vector3.new(1,2,1) then
            if each.Name == "Right Leg" then
                each:Destroy()
            elseif each.Name == "Left Leg" then
                each:Destroy()
            else
                each.Transparency = 1
            end
        end
    end
    -- Notification for debugging purposes
    print(player.Name.." has been successfully babified.")
end)

Old baby script:

debounce=false

function onTouched(hit)
    if hit.Parent ~= nil then
        if (hit.Parent:findFirstChild("Humanoid") == nil) then return end
        if (hit.Parent:findFirstChild("IsaMorph") ~= nil) then return end
        local human = hit.Parent:findFirstChild("Humanoid") 
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local char = human.Parent
        if (human ~= nil) and debounce == false then
            debounce = true
            if char:findFirstChild("Infant") == nil then
                local mesh = char.Head:findFirstChild("Mesh") 
                mesh.Scale = Vector3.new(1, 1, 1) 
                local torso = char.Torso
                torso.Transparency = 1
                torso.CanCollide = false
                if char:findFirstChild("FakeTorso") ~= nil then
                    char:findFirstChild("FakeTorso"):remove()
                end
                local body = Instance.new("Part")
                body.BrickColor = BrickColor.new(1)
                body.Parent = char
                body.Position = torso.Position
                body.Name = "FakeTorso"
                body.formFactor = "Symmetric"
                body.Size = Vector3.new(1,1,1)

                local w1 = Instance.new("Weld")
                w1.Parent = torso
                w1.Part0 = w1.Parent
                w1.Part1 = body
                w1.C1 = CFrame.new(0, 0.25, 0)
                local w2 = Instance.new("Weld")
                w2.Parent = torso
                w2.Part0 = w1.Parent
                w2.Part1 = char.Head
                w2.C1 = CFrame.new(0, -0.8, 0)
                local bodymesh = Instance.new("SpecialMesh")
                bodymesh.Scale = Vector3.new(1.2, 1.5, 1.2)
                bodymesh.Parent = body
                local rightleg = char:findFirstChild("Right Leg")
                if rightleg~= nil then
                    rightleg:remove()
                end
                local leftleg = char:findFirstChild("Left Leg")
                if leftleg ~= nil then
                    leftleg:remove()
                end
                local marker = Instance.new("StringValue")
                marker.Parent = char
                marker.Name = "IsaMorph"
                characterparts = char:getChildren() 
                for i=1,#characterparts do 
                    if characterparts[i].className == "Part" then 
                        characterparts[i].Locked = false
                    end 
                    if characterparts[i].className == "Hat" then 
                        characterparts[i].Handle.Locked = false
                    end 
                end 
            end
        end
        debounce = false
    end
    print ("scriptcomplete")
end

script.Parent.Touched:connect(onTouched)
0
Never mind, I figured it out. Fireorius 51 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

R15 does not have a torso, use UpperTorso

0
I'm not using R15, I'm using R6. Fireorius 51 — 7y
Ad

Answer this question