RB-004
Roblox moving platform script
A platform that slides back and forth between two points using TweenService.
- Script type
- Script
- Where it goes
- Inside the platform Part
- Category
- World and effects
For your own game in Roblox Studio. Not for use in other people's games.
The code
-- Moving platform: slides from its start position to START + OFFSET and back.
local OFFSET = Vector3.new(0, 0, 40) -- how far to move (x, y, z in studs)
local TRAVEL_TIME = 4 -- seconds for one trip
local WAIT_AT_ENDS = 1 -- seconds to pause at each end
local TweenService = game:GetService("TweenService")
local platform = script.Parent
platform.Anchored = true
local startPosition = platform.Position
local endPosition = startPosition + OFFSET
local info = TweenInfo.new(TRAVEL_TIME, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local forward = TweenService:Create(platform, info, { Position = endPosition })
local backward = TweenService:Create(platform, info, { Position = startPosition })
while true do
forward:Play()
forward.Completed:Wait()
task.wait(WAIT_AT_ENDS)
backward:Play()
backward.Completed:Wait()
task.wait(WAIT_AT_ENDS)
endHow to set it up
- Insert a flat Part for the platform.
- Add a Script inside it and paste the code.
- Put the platform where you want it to start. The code reads its position when the game starts.
- Play and jump on. Players ride on top of it.
Change it
- Change OFFSET to Vector3.new(0, 30, 0) to make an elevator.
- Sine easing makes it slow down at each end. Use Enum.EasingStyle.Linear for a steady speed.
- Make sure the path is clear of walls, or the platform will pass through them without stopping.
More in World and effects
More Roblox tools
- Shirt and pants templatesFree Roblox clothing templates to download: hoodies, jerseys, jeans, joggers and more.
- Robux tax calculatorWork out what you receive after the marketplace fee, or what to charge.
- Robux to USD calculatorConvert earned Robux to dollars at a DevEx rate you can edit.
- Shirt and pants template makerColour each panel of the 585×559 clothing template and download it.
- Username generatorGenerate usernames that fit the 3–20 character rule.