Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

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)

1 comment

0

That doesnt make it glide, that makes it just go to that point.

This discussion is preserved as it was. New answers, comments, and votes are closed.