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

A better way to change morphs?

Asked by 9 years ago

I'm working on a RP game and I want the gui I have to work differently than before. This gui I have allows one to switch skins/forms based on the character they're playing as (Example: Samus, Zero Suit Samus; Zelda, Sheik)

The problem I have with the gui is that the player has to use a button to remove the morph as apposed to clicking on the other skin and have the skins swap automatically.

Here's the script I have for the Morphing:

Speed = 25 -- This is the character's speed! 16 is normal walkspeed.

debounce = false
script.Parent.MouseButton1Click:connect(function()
if debounce == false then
local player = script.Parent.Parent.Parent.Parent.Parent
local c = player.Character:GetChildren()
if player ~= nil then
    debounce = true
    for i = 1, #c do
        if (c[i].ClassName == "Hat") then
            c[i]:Destroy()
        end
        wait()
    end

    player.Character.Torso.Transparency = 1
    player.Character.Head.Transparency = .99
    if(player.Character.Head:FindFirstChild("face"))then
        player.Character.Head.face.Parent = player.Character
    end
    player.Character:FindFirstChild("Left Arm").Transparency = 1
    player.Character:FindFirstChild("Left Leg").Transparency = 1
    player.Character:FindFirstChild("Right Arm").Transparency = 1
    player.Character:FindFirstChild("Right Leg").Transparency = 1
    player.Character.Humanoid.WalkSpeed = Speed

    local p = game.Lighting:FindFirstChild("Peach"):Clone()
    p.Parent = player.Character
    p.CFrame = CFrame.new(player.Character.Torso.Position)
    p.Anchored = false

    local Y = Instance.new("Weld")
    Y.Part0 = player.Character.Torso
    Y.Part1 = p
    Y.Parent = Y.Part0

    itemlist = script.Parent:FindFirstChild("StartTools"):GetChildren()

    if #itemlist ~= 0 then
        for i= 1, #itemlist do
            local itemc = itemlist[i]:Clone()
            itemc.Parent = player.Backpack
            wait()
        end
    end
    wait(1)
    debounce = false
end

and here's the remove button:

script.Parent.MouseButton1Click:connect(function()
local player = script.Parent.Parent.Parent.Parent
player.Character.Torso.Transparency = 1
 player.Character:FindFirstChild("Left Arm").Transparency = 1
 player.Character:FindFirstChild("Left Leg").Transparency = 1
 player.Character:FindFirstChild("Right Arm").Transparency = 1
 player.Character:FindFirstChild("Right Leg").Transparency = 1
 player.Character.Head.Transparency = 0.99
 if(player.Character:FindFirstChild("fac") ~= nil)then
player.Character.face.Parent = player.Character.Head
 end 

 g = player.Character:GetChildren()
 for i = 1,#g do
    if(g[i].ClassName == "Part")then
        if(g[i].Size == Vector3.new(1, 1, 1))then
            g[i]:Destroy()
    end
end
0
Please fix the formatting for your code block Goulstem 8144 — 9y

Answer this question