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

How to make a part move from one spot to another?

Asked by 6 years ago

So I was watching a few videos on how to make a script to make an object go up and down and one going from left to right but to no avail they would end up glitching or not doing anything or just completely misbehaving. Would someone mind helping me please.

Here is the set up I have then I will show you the script I used last. So one object above is called Part1 and an object below is called Part2 and the object that needs to be moving when the game starts is called MovingPart. Also they are grouped together and the group is called Moving. So once the game starts Moving part is supposed to fuse into the part that I set it to in the script in this case I chose Part1. Then from there it goes to Part2. Then in the code was added while true do so I can make it last forever. The problem is this one does nothing when the game starts.

Also when someone else tried to help me before they said something about cframes but I am a noob at scripting and could not find anything that would help me on the internet to help me how to fix my problem. So if you can fix it can you help explain so I may try and be better equipped fixing my own problems in the future. Thanks in advance!

Please help here is the script:

local bodyposition = script.Parent.MovingPart.BodyPosition
local p1 = script.Parent.Point1
local p2 = script.Parent.Point2

bodyposition.Position = p1.Position

while true do
    wait(3)
    bodyposition.Position = p1.Position
    wait(3)
    bodyposition.Position = p2.Position
end
0
Not sure about the ClassName of Point1, but if it's a part then bodyposition.CFrame = p1.CFrame blowup999 659 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

You need to use TweenService. It's a service which much easier to script.

You need to do game:GetService("TweenService") to get it's service for you to do it.

0
So where does the moving part come into when using this nightcrawl47 2 — 6y
0
When you set, the speed of the movement, how many times should be played again, easing direction, easing style. Then you have to set where the block would go so you need CFrame in a variable and set it up into a function and make play with the :Play() RichMan4b 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

The reason why your script is not doing anything is because the body position must be located inside the part you want to move.

Another way to move objects around is to interpolate their positions or CFrames using a function called lerp. This can often give you finer control over what you are moving and avoid the glitchiness characteristic of many roblox body movers. If you are interested in learning more about lerping, you can visit this wiki page: http://wiki.roblox.com/index.php?title=Lerp

Answer this question