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

Is there a way you could make a part move to another position?

Asked by
iLordy 27
9 years ago

Like when a player touches a block it makes a certain part move/slide to another position

2 answers

Log in to vote
0
Answered by 9 years ago

Hmm, try this:

script.Parent.Touched:connect (function()
    script.Parent.Position = Vector3.new(0, 0, 0) -- Wherever you want
end)

Or there is also:

script.Parent.Touched:connect (function()
    script.Parent.Position = (script.Parent.Position + Vector3.new(1, 0, 0)) --{ Moves 1 to the right of the current position. Edit accordingly to X, Y, Z. }--
end)

Or if you can come up with anything else form that! Hope that helps.

Ad
Log in to vote
1
Answered by
Necrorave 560 Moderation Voter
9 years ago

There are a couple ways of doing this.

Changing Position directly

Changing the position of an object directly requires you to change the Position property in the part you are trying to move.

You would need to use something called Vector3 in order to accomplish this, since position hold 3 different values known as X, Y, and Z

Example:

part.Position = Vector3.new(x,y,z) --Takes 3 arguments

Using CFraming

Another method would to use one of the many CFrame constructors.

There are many ways to use CFrame, but I will only show you one method.

part.CFrame = CFrame.new(x,y,z)--Works similar to our previous method, but CFrame has a lot of other uses

Let me know if you have any questions!

More info on CFraming

More info on Vector3

Answer this question