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

Smoothly moving a brick?

Asked by
Mystdar 352 Moderation Voter
10 years ago

In this part of a script:

move.CFrame = CFrame.new(10,0,0)

Say that 'ham's' old position was (0, 0, 0) then it would move 10 studs along the X axis, however it seems to teleport rather than move smoothly along, is there a way to make it move smoothly? Perhaps using the (body)velocity of the part to make it smooth? Please amend my script to make it smoothly run Also can you make the speed in which it moves changeable too. The damage it deals on touch with a ROBLOXian (Lets say 40) Finally please may you annotate along the way? Thanks.

0
Fixed mine. HexC3D 830 — 10y

1 answer

Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
10 years ago

To make a brick move smoothly you'll need to have a loop that runs a fair amount of times with a small wait and small movement increments.

part = script.Parent -- Object Tree location of part
speed = .1 -- Speed of the movements, the lower the number, the faster and more smooth
distance = 10 --The distance to move along the axis
timestorun = distance * 10 -- Times to run, don't change this as it allows for smooth transitions
for i = 1, timestorun  do -- i represents the index or current position of the loop, it starts at one and goes to whatever the times to run is, meaning it will run that many times
    wait(speed) -- Wait for the designated speed time
    part.CFrame = CFrame.new(part.Position + Vector3.new(0.1,0,0)) -- Change the CFrame by 0.1 to allow for a smooth transition
end -- End the loop

0
So this will make it move by 0.1? Mystdar 352 — 10y
0
Yes, it will move by 0.1 on the X-axis 100 times, meaning it will move 10 studs along the X-axis. Sublimus 992 — 10y
0
But if you wanted to, you can change the distance to lets say, 20, and it would move 0.1 studs on the X-axis 200 times, meaning it would move 20 studs. Sublimus 992 — 10y
Ad

Answer this question