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

Why doesn't my morph script work?

Asked by 8 years ago

I wrote this script to make so that when the player(s) enter the game it clones the morph in the character, but I tried and didn't work. I'm a beginner scripter and I would appreciate if you guys can help.

local Player = game.Players.LocalPlayer.Character
local morph = game.ReplicatedStorage.Morphs.[Robloxian 2.0]
function playerentered()
if morph then 
morph:GetChildren()
morph:clone()
morph.Parent = Player 
script.Parent:connect(playerentered)

1 answer

Log in to vote
0
Answered by 8 years ago
--Insert this into your spawnpoints, so the players will spawn with it happening 
function onTouch(hit)
        local Morph = game.ReplicatedStorage.Morphs:findFirstChild("Robloxian 2.0")
        BodyParts = hit.Parent:GetChildren()
        for i,b in pairs(BodyParts) do
            if (b.className == "Humanoid") then
            end
            wait(0.1)
        end

        BodyParts = hit.Parent:GetChildren()
        for i,b in pairs(BodyParts) do
            if (b.className == "CharacterMesh") or (b.className == "Hat") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
                b:Remove()
            end
            if (b.className == "Part") then
            if (b.Name == "Head") then
                    if (b:findFirstChild("Mesh") ~= nil) then
                        b.Mesh:Remove()
                    end
                end
            end
            wait(0.1)
        end

        BodyParts = Morph: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 = hit.Parent
            end
        if (b.className == "Part") then
            if (b.Name == "Head") then
            if (b:findFirstChild("Mesh") ~= nil) then
                        b.Mesh:Clone().Parent = hit.Parent.Head
                    end
                end
            end
        wait(0.1)
        end
    end
script.Parent.Touched:connect(onTouch)

Edit this to your needs, and If you have any questions, PM me or reply to this answer.

Ad

Answer this question