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

Keeping morph after death?

Asked by
j1011 0
9 years ago

In order for this to work morph the creature you want to turn into and then place them into the Morphs Folder in the MorphGui . This will auto generate the morph buttons when you start. But when i die i need to click it again to morph, is there anyway i can keep the morph? after death? Maybe looping? i don't know where to start.

local Player = script.Parent.Parent.Parent
local Me = Player.Character or Player.CharacterAdded:wait()
local Morphs = script.Parent.Morphs:GetChildren()

function Morph(Suit)
if Me:findFirstChild("Chest") == nil then
    for i,v in pairs(Me:GetChildren()) do
        if v.ClassName == "Part" then
            v.Transparency = 1
        end
    end
    if Me.Head:findFirstChild("face") ~= nil then
    Me.Head.face:Destroy()
    end

    if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Arm1") == nil and Suit:findFirstChild("Arm1") ~= nil then
    local g = Suit.Arm1:clone()
            g.Parent = Me
            local C = g:GetChildren()
            for i=1, #C do
                if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then
                    local W = Instance.new("Weld")
                    W.Part0 = g.Middle
                    W.Part1 = C[i]
                    local CJ = CFrame.new(g.Middle.Position)
                    local C0 = g.Middle.CFrame:inverse()*CJ
                    local C1 = C[i].CFrame:inverse()*CJ
                    W.C0 = C0
                    W.C1 = C1
                    W.Parent = g.Middle
                end
                    local Y = Instance.new("Weld")
                    Y.Part0 = Me["Left Arm"]
                    Y.Part1 = g.Middle
                    Y.C0 = CFrame.new(0, 0, 0)
                    Y.Parent = Y.Part0
            end

            local h = g:GetChildren()
            for i = 1, # h do
            if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then
            h[i].Anchored = false
            h[i].CanCollide = false
            end
            end
        end

        if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Arm2") == nil and Suit:findFirstChild("Arm2") ~= nil then
            local g = Suit.Arm2:clone()
            g.Parent = Me
            local C = g:GetChildren()
            for i=1, #C do
                if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then
                    local W = Instance.new("Weld")
                    W.Part0 = g.Middle
                    W.Part1 = C[i]
                    local CJ = CFrame.new(g.Middle.Position)
                    local C0 = g.Middle.CFrame:inverse()*CJ
                    local C1 = C[i].CFrame:inverse()*CJ
                    W.C0 = C0
                    W.C1 = C1
                    W.Parent = g.Middle
                end
                    local Y = Instance.new("Weld")
                    Y.Part0 = Me["Right Arm"]
                    Y.Part1 = g.Middle
                    Y.C0 = CFrame.new(0, 0, 0)
                    Y.Parent = Y.Part0
            end

            local h = g:GetChildren()
            for i = 1, # h do
            if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then
            h[i].Anchored = false
            h[i].CanCollide = false
            end
            end     
        end

        if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Leg1") == nil and Suit:findFirstChild("Leg1") ~= nil then
            local g = Suit.Leg1:clone()
            g.Parent = Me
            local C = g:GetChildren()
            for i=1, #C do
                if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then
                    local W = Instance.new("Weld")
                    W.Part0 = g.Middle
                    W.Part1 = C[i]
                    local CJ = CFrame.new(g.Middle.Position)
                    local C0 = g.Middle.CFrame:inverse()*CJ
                    local C1 = C[i].CFrame:inverse()*CJ
                    W.C0 = C0
                    W.C1 = C1
                    W.Parent = g.Middle
                end
                    local Y = Instance.new("Weld")
                    Y.Part0 = Me["Left Leg"]
                    Y.Part1 = g.Middle
                    Y.C0 = CFrame.new(0, 0, 0)
                    Y.Parent = Y.Part0
            end

            local h = g:GetChildren()
            for i = 1, # h do
            if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then
            h[i].Anchored = false
            h[i].CanCollide = false
            end
            end
        end

        if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Leg2") == nil and Suit:findFirstChild("Leg2") ~= nil then
            local g = Suit.Leg2:clone()
            g.Parent = Me
            local C = g:GetChildren()
            for i=1, #C do
                if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then
                    local W = Instance.new("Weld")
                    W.Part0 = g.Middle
                    W.Part1 = C[i]
                    local CJ = CFrame.new(g.Middle.Position)
                    local C0 = g.Middle.CFrame:inverse()*CJ
                    local C1 = C[i].CFrame:inverse()*CJ
                    W.C0 = C0
                    W.C1 = C1
                    W.Parent = g.Middle
                end
                    local Y = Instance.new("Weld")
                    Y.Part0 = Me["Right Leg"]
                    Y.Part1 = g.Middle
                    Y.C0 = CFrame.new(0, 0, 0)
                    Y.Parent = Y.Part0
            end

            local h = g:GetChildren()
            for i = 1, # h do
            if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then
            h[i].Anchored = false
            h[i].CanCollide = false
            end
            end
    end

        if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Chest") == nil and Suit:findFirstChild("Chest") ~= nil then
            local g = Suit.Chest:clone()
            g.Parent = Me
            local C = g:GetChildren()
                    local R = Me:GetChildren()
            for i=1, #R do
                if R[i].className == "Hat" then
                    R[i]:Destroy()
                end
            end
            for i=1, #C do
                if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then
                    local W = Instance.new("Weld")
                    W.Part0 = g.Middle
                    W.Part1 = C[i]
                    local CJ = CFrame.new(g.Middle.Position)
                    local C0 = g.Middle.CFrame:inverse()*CJ
                    local C1 = C[i].CFrame:inverse()*CJ
                    W.C0 = C0
                    W.C1 = C1
                    W.Parent = g.Middle
                end
                    local Y = Instance.new("Weld")
                    Y.Part0 = Me.Torso
                    Y.Part1 = g.Middle
                    Y.C0 = CFrame.new(0, 0, 0)
                    Y.Parent = Y.Part0
            end

            local h = g:GetChildren()
            for i = 1, # h do
            if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then
            h[i].Anchored = false
            h[i].CanCollide = false
            end
            end 
        end
else
    Me.Arm1:Destroy()
    Me.Arm2:Destroy()
    Me.Chest:Destroy()
    Me.Leg1:Destroy()
    Me.Leg2:Destroy()
    Morph(Suit)
end

end

local enabled = true
local y = 0
for i,v in pairs(Morphs) do
    local Button = script.TextButton:Clone()
    Button.Position = UDim2.new(0,0,y*0.1,0)
    y = y + 1
    Button.Name = v.Name
    Button.Text = v.Name
    Button.Parent = script.Parent.Background.Box

    Button.MouseButton1Down:connect(function()
        if not enabled then return end
        enabled = false
        Morph(v)
        enabled = true
    end)

end



0
The way I would do it is simply by adding a vaiable to the player named somthing like "MorphVal" which you will read on the player sporn event to determine what morph to do. This value will need to be changed when the player picks a new morph User#5423 17 — 9y
0
Shorten the code to snippet's please. MessorAdmin 598 — 9y
1
these questions old af epiclightining 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

There is an event called .CharacterAdded in Player. This event activates when you respawn. From there, you can launch your morph script from there.

Ad

Answer this question