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

How to make a door open when you approach it?

Can someone tell me how to make a door open when you approach it?

2 comments

0

Scripting helpers is not a request website, you need to provide an script so we can fix it

0

I’m so sorry leamir please don’t close this question :(

1 answer

✓ Accepted answer

Put this script inside a block in front of the door(like a carpet or something).

local Door = game.Workspace.Door --door needs to be a model/part named "Door"
local part = script.Parent -- this is the part in front of the door(a carpet or something)


part.Touched:Connect(function()
	Door.CanCollide = false
	wait(10) --Change 10 if you want longer time
	Door.CanCollide = true
end)

This script basically makes the door un-collidable when the player touches the part for 10 seconds (or more if you need). The "Door.CanCollide = false" makes the door able to be walked through, and after 10 seconds back to being able to be collided with(you can put 2 of these parts on each side of door)

To make the double opening door, you will need 2 sets of doors, the closed position and open position. When you're done with that, make a script inside the carpet/part that looks a little like this:

-- doors in closed position(you need 2 of them in the closed position)
local Door1_1 = game.Workspace.Door --door needs to be a model/part named "Door"
local Door1_2
-- doors in open position (You need 2 of them on each side)
local Door2_1
local Door2_2
--Stepping part
local part = script.Parent -- this is the part in front of the door(a carpet or something)

part.Touched:Connect(function()
	if Door1_1.Visible == true and Door1_1.CanCollide == true or Door1_2.Visible == true and Door1_2.CanCollide == true then
		Door1_1.CanCollide = false
		Door1_2.CanCollide = false
		Door1_1.Transparency = 1
		Door1_2.Transparency = 1
		--this has made the closed doors invisible
		Door2_1.CanCollide = true
		Door2_2.CanCollide = true
		Door2_1.Transparency = 0
		Door2_2.Transparency = 0
		-- this has made the open doors visible
		wait(10) --change the 10 to whatever time you want the doors to be open
		Door1_1.CanCollide = true
		Door1_2.CanCollide = true
		Door1_1.Transparency = 0
		Door1_2.Transparency = 0
		--this has made the closed doors visible
		Door2_1.CanCollide = false
		Door2_2.CanCollide = false
		Door2_1.Transparency = 1
		Door2_2.Transparency = 1
		-- this has made the open doors invisible
	end
end)

When you step on the block it makes the closed doors invisible and the open ones visible, and after 10 seconds it returns to normal, this could have been done simpler but I wanted to show you the way you could remember it.

5 comments

0

Thank you so much! But I was thinking of a script that works on 2 door that opens sideways like in stores in to real life

0

I can edit the script if you would like?

0

Yes sir!

0

Done.

0

Thank you so much!

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