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

Morph script supposed to morph only 1 player not working?

Asked by
Kegani 31
7 years ago
game.Workspace.ChildAdded:connect(function(plr)
    local name = plr.Name
    local playersinplayers = game.Players:FindFirstChild(plr.Name)
    if name == "Player1" then
        if playersinplayers ~= nil then
            playersinplayers.CanLoadCharacterAppearance = false
            plr.Head.face.Texture = "rbxassetid://28257733"
            local bodycolors = Instance.new("BodyColors", plr)
            local bodycolors = Instance.new("BodyColors", plr)
            bodycolors.RightArmColor = BrickColor.new("Pastel brown")
            bodycolors.LeftArmColor = BrickColor.new("Pastel brown")
            bodycolors.LeftLegColor = BrickColor.new("Dark stone grey")
            bodycolors.RightLegColor = BrickColor.new("Dark stone grey")
            bodycolors.TorsoColor = BrickColor.Random()
            bodycolors.HeadColor = BrickColor.new("Pastel brown")
        end
    end
end)

This script is supposed to morph a player (named Player1 as said in the script), but there's an error breaking the script and nothing is written in output. (and I forgot where the script error notified was)

0
This script works but It would be best to not use the ChildAdded as there is a CharacterAdded event User#5423 17 — 7y
0
Thanks! Kegani 31 — 7y

2 answers

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
7 years ago
Edited 7 years ago

There is no error, but consider using PlayerAdded and CharacterAdded instead.

game.Players.PlayerAdded:connect(function(player)
    if player.Name == "Player1" then
        player.CanLoadCharacterAppearance = false
        player.CharacterAdded:connect(function(char)
            local bodycolors = Instance.new("BodyColors", char)
            char.Head.face.Texture = "rbxassetid://28257733"
            bodycolors.RightArmColor = BrickColor.new("Pastel brown")
            bodycolors.LeftArmColor = BrickColor.new("Pastel brown")
            bodycolors.LeftLegColor = BrickColor.new("Dark stone grey")
            bodycolors.RightLegColor = BrickColor.new("Dark stone grey")
            bodycolors.TorsoColor = BrickColor.Random()
            bodycolors.HeadColor = BrickColor.new("Pastel brown")
        end)
    end
end)
0
Thanks! Kegani 31 — 7y
Ad
Log in to vote
0
Answered by 6 years ago

-- Smart Morph script by jamiethegreatQ777

while (script:findFirstChild("InfoRemover") == nil) do wait(0.1) end

local g = Instance.new("ScreenGui") g.Name = "InfoBox"

local t = Instance.new("TextLabel") t.Name = "Info" t.Text = "Fixed Morph Script By JamiethegreatQ777" t.BackgroundTransparency = 0 t.BackgroundColor3 = Color3.new(0, 0, 0) t.BorderSizePixel = 0 t.TextColor3 = Color3.new(1, 1, 1) t.Position = UDim2.new(0, 0, 0.95, 0) t.Size = UDim2.new(1, 0, 0.05, 0) t.Parent = g

local CanMorph = nil local Lock = nil

local s = script.InfoRemover:Clone() s.Parent = g s.Disabled = false

script.Parent.BrickColor = BrickColor.new("Bright yellow")

function onTouch(hit) if (Lock == nil) then Lock = true script.Parent.BrickColor = BrickColor.new("Medium stone grey")

    CanMorph = nil
    BodyParts = hit.Parent:GetChildren()
    for i,b in pairs(BodyParts) do
        if (b.className == "Humanoid") then
            CanMorph = true
        end
        wait(0.1)
    end
    if (CanMorph == nil) then
        script.Parent.BrickColor = BrickColor.new("Bright yellow")
        Lock = nil
        return
    end

    script.Parent.BrickColor = BrickColor.new("Black")
    g.Parent = game.Players:findFirstChild(hit.Parent.Name).PlayerGui

    BodyParts = hit.Parent:GetChildren()
    for i,b in pairs(BodyParts) do
        if (b.className == "Hat") 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.Parent: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 == "BodyColors") and (hit.Parent:findFirstChild("Body Colors") ~= nil) then
            hit.Parent:findFirstChild("Body Colors").HeadColor= b.HeadColor
            hit.Parent:findFirstChild("Body Colors").LeftArmColor= b.LeftArmColor
            hit.Parent:findFirstChild("Body Colors").LeftLegColor= b.LeftLegColor
            hit.Parent:findFirstChild("Body Colors").RightArmColor= b.RightArmColor
            hit.Parent:findFirstChild("Body Colors").RightLegColor= b.RightLegColor
            hit.Parent: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 = hit.Parent.Torso
                elseif (script.Parent.Parent.Torso:findFirstChild("Decal") ~= nil) then
                    b.Decal:Clone().Parent = hit.Parent.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.Parent.Head:findFirstChild("Decal") ~= nil) then
                    hit.Parent.Head.face.Texture = b.Decal.Texture
                end
                if (b:findFirstChild("Mesh") ~= nil) then
                    b.Mesh:Clone().Parent = hit.Parent.Head
                end
            end
        end
        if (b.className == "Hat") then
            local h = Instance.new("Hat")
            h.Name = b.Name
            h.AttachmentPos = b.AttachmentPos
            b.Handle:Clone().Parent = h
            h.Parent = hit.Parent
        end
        wait(0.1)
    end

    g.Parent = nil
    script.Parent.BrickColor = BrickColor.new("Bright yellow")
    Lock = nil
end

end

script.Parent.Touched:connect(onTouch)

Answer this question