How to move wall panels up and down in specific increments using buttons smoothly?

Hi, I’m not so experienced when it comes to using CFrames to animate, I would like to move the wall panels shown below, up and down individually using a press of separate up and down buttons.

Increments of about 5 studs is fine and the panels can only go 25 studs down from their origin.
I have searched up tutorials, but I’m still confused, if you got a suggestion or solution please answer.

Thanks!

Something like this you could probably type the explanation of what you want into the Roblox script generator in Studio to get a script for. You’d have to modify it for precisely what you need, but it’ll give you a starting point.

Will give that an attempt right now

Yeah this was sufficient enough, For anyone who needs the code its below:

-- Script for smoothly animating a part up and down based on click input with customizable travel time

local part = script.Parent  -- Assuming this script is a child of the part

local upPart = part.UpPart  -- Replace "UpPart" with the actual name of your up part
local downPart = part.DownPart  -- Replace "DownPart" with the actual name of your down part

local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Velocity = Vector3.new(0, 0, 0)  -- Initial velocity
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)  -- Infinite force
bodyVelocity.Parent = part

local increment = 5  -- Amount to increment the position by
local travelTime = 1  -- Time in seconds for the part to travel the distance of the increment

local function onUpPartClick()
    local targetPosition = part.Position + Vector3.new(0, increment, 0)
    local distance = (targetPosition - part.Position).Magnitude
    local velocity = distance / travelTime
    bodyVelocity.Velocity = Vector3.new(0, velocity, 0)
end

local function onDownPartClick()
    local targetPosition = part.Position - Vector3.new(0, increment, 0)
    local distance = (targetPosition - part.Position).Magnitude
    local velocity = distance / travelTime
    bodyVelocity.Velocity = Vector3.new(0, -velocity, 0)
end

upPart.ClickDetector.MouseClick:Connect(onUpPartClick)
downPart.ClickDetector.MouseClick:Connect(onDownPartClick)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.