Moving Part
Moving Part
Moving Part
Where to put this script
Where to put this script
Inside the part you want to move
Inside the part you want to move
Script
Script
Can be modified for x, y or z dimension
Can be modified for x, y or z dimension
Bounds can be adjusted the > and < signs
Bounds can be adjusted the > and < signs
wait() can be adjusted for speed
wait() can be adjusted for speed
local part = script.Parent
local dir = 1
while true do
part.Position = part.Position + Vector3.new(1*dir,0,0)
wait(.1)
if (part.Position.X > 100) then
dir = -1
end
if (part.Position.X < -100) then
dir = 1
end
end
Type 1
Type 1
The part moves forward by the amount set by distance
The part moves forward by the amount set by distance
The part waits the amount of time set by stopTime
The part waits the amount of time set by stopTime
stopTime is increased by 1 so the the next movement happens after 2 seconds
stopTime is increased by 1 so the the next movement happens after 2 seconds
The process repeats
The process repeats
Result: each movement stays at the position longer than the prior movement
Result: each movement stays at the position longer than the prior movement
local part = script.Parent
local dir = 1
local stopTime = 1
local distance = 1
while true do
part.Position = part.Position + Vector3.new(distance*dir,0,0)
wait(stopTime)
stopTime = stopTime + 1
if (part.Position.X > 100) then
dir = -1
end
if (part.Position.X < -0.1) then
dir = 1
end
end