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

How to move a part using scripts?

Asked by 9 years ago

Is this?

Brick = script.Parent
Door1 = game.Workspace.Door.Left
Door2 = game.Workspace.Door.Right

function onTouched(hit)
    if hit.Parent then
        Door1.Move = Right 1
        Door2.Move = Left 1
        wait(3)
        Door1.Move = Left 1
        Door2.Move = Right 1
    end
end

Brick.MouseButton1Click:connect(onTouched)

1 answer

Log in to vote
0
Answered by 9 years ago

Try this code instead. Lua doesn't use direction. It uses numbers and Cframe values (at least I know this method.)

function onClicked()

        for i=1,20 do
            script.Parent.Parent.Lock3.CFrame = script.Parent.Parent.Lock3.CFrame * CFrame.new(0, 1, 0)
            script.Parent.Parent.Lock4.CFrame = script.Parent.Parent.Lock4.CFrame * CFrame.new(0, -1, 0)
            wait(0.01)
        end

        for i=1,20 do
            script.Parent.Parent.Lock3.CFrame = script.Parent.Parent.Lock3.CFrame * CFrame.new(0, -1, 0)
            script.Parent.Parent.Lock4.CFrame = script.Parent.Parent.Lock4.CFrame * CFrame.new(0, 1, 0)
            wait(0.01)
        end
end

script.Parent.Parent.Open.ClickDetector.MouseClick:connect(onClicked)

0
You mean script.Parent. StickMasterNinja2 0 — 9y
0
No. This script works perfectly fine. Just change the names to what you need. :) TheRings0fSaturn 28 — 9y
Ad

Answer this question