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

How to move a part using scripts?

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

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)

2 comments

0

You mean script.Parent.

0

No. This script works perfectly fine. Just change the names to what you need. :)

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