#how to make a platform move

1 messages · Page 1 of 1 (latest)

zenith kernel
#

how to make a platform move using a script
i need it for my obby

frozen sluice
#

tweenservices

reef turret
#

Make it anchored false and can collide true in properties

#

local platform = script.Parent
local speed = 5
local range = 20
local direction = 1

local startPos = platform.Position

game:GetService("RunService").Heartbeat:Connect(function(dt)
local offset = Vector3.new(speed * direction * dt, 0, 0)
platform.Position = platform.Position + offset

if (platform.Position - startPos).Magnitude >= range then
    direction = -direction
end

end)

#

Put this script and see if it works

#

Put this script inside of the part u want to move

#

But if u want the player to be able to stand on it then…

#

Make anchored true

#

Anchored false*

#

Can collide true

#

Massless true

#

Make sure the part is in a model

#

Copy this!

wise lodgeBOT
#

studio** You are now Level 2! **studio

reef turret
#

local platform = script.Parent
local speed = 5 -- studs per second
local range = 20 -- how far it moves before turning around
local direction = 1
local startPos = platform.PrimaryPart.Position

game:GetService("RunService").Heartbeat:Connect(function(dt)
local offset = Vector3.new(speed * direction * dt, 0, 0)
platform:SetPrimaryPartCFrame(platform:GetPrimaryPartCFrame() + offset)

if (platform.PrimaryPart.Position - startPos).Magnitude >= range then
    direction = -direction
end

end)

#

If it doesn’t work then idk

flint phoenix
#

real

#

before using the script i suggest you understand whats going on in it

#

it will help you in the future and you'll get new knowledges

reef turret
#

Yes

flint verge
dreamy iris
#

tween would be the best instead of having to use runservice.

#

since it only requires a few code to make it move

reef turret
#

Ig yes