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

How do I make a sliding door?

I'm trying to make a door which, when a button is pressed, slides to the right. But it's sort of different to that. I want my door to be like this:

When a button is pressed, several rocks move to the right, uncovering a secret tunnel. Is it possible to do this? If so, help me out! :)

1 answer

As thumb rule you can say that you can make everything. Some things are technically impossible and some things are possible but will overwhelm CPU resources.

That's absolutely not the case in this. Basically, you have rocks, which you could say are several doors which you are sliding to the right. This is very objective though as I don't really know what to "right" is, it depends on your viewpoint.

I would create it as this:

function drag(doors)
	for i = 1,30 do
		for i, rock in pairs(doors) do
			rock.CFrame = rock.CFrame * CFrame.new(0,0,0.2)
		end
		wait()
	end
	wait(5)
	for i = 1,30 do
		for i,rock in pairs(doors) do
			rock.CFrame = rock.CFrame * CFrame.new(0,0,-0.2)
		end
	end
end

local doors = {}
table.insert(doors, game.Workspace.Rock1)
table.insert(doors, game.Workspace.Rock2)
-- and so on
-- an event happens:
drag(doors)

You will notice however that the doors are sliding to the left, or in the wall, or from it. You need to either change the CFrames to one of the following:

CFrame.new(0,0,-0.2) and CFrame.new(0,0,0.2)

or

CFrame.new(0.2,0,0) and CFrame.new(-0.2,0,0)

or

CFrame.new(-0.2, 0, 0) and CFrame.new(0.2,0,0)

5 comments

0

How do I make it so that when I click a button it moves?

0

Call drag(doors) when the button is clicked, thus ClickDetector.MouseClick:connect(function() drag(doors) end)

0

I tried making the doors and it didn't work, I put the doors I wanted in a group named 'Doors' and made changes to the script: table.insert(doors, game.Workspace.Doors.Rock1)

0

try doors = game.Workspace.Doors:GetChildren() - remove every "table.insert" line.

0

Still doesn't work.

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