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

What is wrong about this script?

Asked by 10 years ago
part = script.parent.parent.Part

script.Parent.Touched:connect(function()

    part.position = Vector3.new(25.55, 1.6, -57.6)
        wait(.05)
    part.position = Vector3.new(25.55, 1.8, -57.6)
        wait(.05)
    part.position = Vector3.new(25.55, 2.0, -57.6)
        wait(.05)

end)

Whenever you hit the part with the script in it, it is supposed to move. That's not working;. Nothing happens when it is touched.

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Remember, Lua is case sensitive. This means that upper and lower cases must be correct.

part = script.Parent.Parent.Part --.Parent is capital

script.Parent.Touched:connect(function()

    part.Position = Vector3.new(25.55, 1.6, -57.6) --Position is capital.
        wait(.05)
    part.Position = Vector3.new(25.55, 1.8, -57.6)
        wait(.05)
    part.Position = Vector3.new(25.55, 2.0, -57.6)
        wait(.05)

end)

However, i would also recommend using a for loop and adding 0.2 to the brick's Position every time.

part = script.Parent.Parent.Part --.Parent is capital

script.Parent.Touched:connect(function()
    for i = 1,3 do
        part.Position = part.Position + Vector3.new(0,0.2,0)
    end
end)
0
I usually do everything capital and stuff. I have fever today, so my head is hurting so badly it is hard to think. Lightdrago 95 — 10y
0
Also, I didn't know how to do loops. Thanks! Lightdrago 95 — 10y
Ad

Answer this question