Like when a player touches a block it makes a certain part move/slide to another position
✓ ANSWER ACCEPTED
Is there a way you could make a part move to another position?
2 answers
✓ Accepted answer
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.
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!
This discussion is preserved as it was. New answers, comments, and votes are closed.
