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

How do I make a brick glide from 1 position to another?

Asked by 9 years ago

I have always needed to know how to make a brick glide. Like not just move there. What im planning to do is make a button that will make the door slide closed when the button is hit but I dont know how to make the door slide. Help would be appreciated.

2 answers

Log in to vote
1
Answered by
4Bros 550 Moderation Voter
9 years ago

A helpful tutorial on making bricks slide is located here on the roblox wiki: http://wiki.roblox.com/index.php?title=Part_sliding

Nevertheless, I'll give you an example right here

local Door = Workspace.Door -- The door
local newPos = Door.Position + Vector3.new(0,20,0) --The position the door will slide to
local Increment = 1 -- The Door will move 1 studs each time it moves
local Time = 10 -- The time it will take to move the door
local Diff = newPos - Door.Position -- The difference between the two positions
local Mag = Diff.magnitude -- The distance between the two points
local Direction = CFrame.new(Door.Position, newPos).lookVector -- The direction the door will move

function MoveDoor() -- Function to move the Door
    for n = 0, Mag, Increment do 
        Door.CFrame = Door.CFrame + (Direction * Increment) -- Door will move in the direction of the new position
        wait( (Time/Mag) * Increment ) -- Time will be divided by the distance and then timed by the increment
    end
end

Workspace.Button.ClickDetector.MouseClick:connect(MoveDoor)
Ad
Log in to vote
0
Answered by 9 years ago

Say you have a part in workspace called "door" and another called "Part." Insert a ClickDetector and a script into "Part" and paste this into it:

local door = workspace.door

function move()
door.Position = door.Position + Vector3.new(0, 5, 0)
end

script.Parent.ClickDetector.MouseClick:connect(move)
0
That doesnt make it glide, that makes it just go to that point. AWESOMEnoob3 3 — 9y

Answer this question