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

Scripting ERROR? (Morphing)

Asked by 8 years ago
local morph = script.Parent.Parent:findFirstChild("Mini-Person")

function touch(part)
    if(part.Parent:findFirstChild("Humanoid") == nil)then return end
    local p = game.Players:findFirstChild(part.Parent.Name)
    if(p == nil)then return end
    local m2 = morph:clone()
    m2.Name = part.Parent.Name
    m2.Torso.Anchored = false
    m2.Torso.Position = m2.Torso.Position + Vector3.new(18.26, 1.23, -35.73)
    m2.Head.Position = m2.Head.Position + Vector3.new(18.26, 1.83, -35.73)
    m2.Left Arm.Position = m2.Left Arm.Position + Vector3.new(17.66, 1.23, -35.73)
    m2.Right Arm.Position = m2.Right Arm.Position + Vector3.new(18.86, 1.23, -35.73)
    m2.Left Leg.Position = m2.Left Leg.Position + Vector3.new(18.46, 0.43, -35.73)
    m2.Right Leg.Position = m2.Right Leg.Position + Vector3.new(18.46, 0.43, -35.73)
    p.Character = m2
    --part.Parent:remove()
    m2.Parent = game.Workspace
    m2:MakeJoints()
end

script.Parent.Touched:connect(touch)

The error is that it thinks that left and arm are two different things. It says "Expected '=', got 'Arm'" when I hover over it. I need the Left Arm because it doesn't could it as a humanoid if its name is LeftArm. Please help me!

1 answer

Log in to vote
1
Answered by
4Bros 550 Moderation Voter
8 years ago

Periods can't get objects that have spaces in their names, or numbers in front of them. A good workaround for this is to use brackets ([]) to get the object you're looking for.

local morph = script.Parent.Parent:findFirstChild("Mini-Person")

function touch(part)
    if(part.Parent:findFirstChild("Humanoid") == nil) then return end
    local p = game.Players:findFirstChild(part.Parent.Name)
    if (p == nil) then return end
    local m2 = morph:clone()
    m2.Name = part.Parent.Name
    m2.Torso.Anchored = false
    m2.Torso.Position = m2.Torso.Position + Vector3.new(18.26, 1.23, -35.73)
    m2.Head.Position = m2.Head.Position + Vector3.new(18.26, 1.83, -35.73)
    m2["Left Arm"].Position = m2["Left Arm"].Position + Vector3.new(17.66, 1.23, -35.73)
    m2["Right Arm"].Position = m2["Right Arm"].Position + Vector3.new(18.86, 1.23, -35.73)

    m2["Left Leg"].Position = m2["Left Leg"].Position + Vector3.new(18.46, 0.43, -35.73)

    m2["Right Leg"].Position = m2["Right Leg"].Position + Vector3.new(18.46, 0.43, -35.73)

    p.Character = m2

    --part.Parent:remove()

    m2.Parent = game.Workspace

    m2:MakeJoints()
end


script.Parent.Touched:connect(touch)

0
@4Bros It says "Workspace.part.MorphScript:12: '<name>' expected near '['" when I tried to load the game.... iiCasual 20 — 8y
0
@iiCasual yeah I had a typo right there, instead of putting a bracket I put a table character, I fixed it now. 4Bros 550 — 8y
0
@4bros it still says Workspace.part.MorphScript:12: '<name>' expected near '[' iiCasual 20 — 8y
0
ok, i edited it again, this time it should work 4Bros 550 — 8y
Ad

Answer this question