Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Scripting ERROR? (Morphing)

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

✓ Accepted answer

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)

4 comments

0

@4Bros It says "Workspace.part.MorphScript:12: '' expected near '['" when I tried to load the game....

0

@iiCasual yeah I had a typo right there, instead of putting a bracket I put a table character, I fixed it now.

0

@4bros it still says Workspace.part.MorphScript:12: '' expected near '['

0

ok, i edited it again, this time it should work

This discussion is preserved as it was. New answers, comments, and votes are closed.