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 script that opens a door

So that once you click the door knob, it opens the door. What are the procedures to connecting all the bricks as well to make them all move once you open it?

2 answers

✓ Accepted answer

Well you would need to use a ClickDetector which you would put inside of the door knob after that you would inset a script into the door knob and the code would look something like this. You might want to weld the knob to the door so that the knob will move with the door.

knob = script.Parent  --The name of the part the script is in
door = script.Parent.Parent.door --the name of the part you want to open
c = Instance.new("ClickDetector",knob) -- adding a clickdetector to it.

function onClick()
	knob.CFrame = knob.CFrame *CFrame.Angles(0,0,1) --changed the position of the door on the z axis
	
end
knob.ClickDetector.MouseClick:connect(onClick) -- connect it and done

This script requires the Door and the Handle (Knob as you chose to call it) to be in a group together.

local Handle=script.Parent 
local Door=Handle.Parent.Door --Door part must be called 'Door'
local = Clicker = Instance.new("ClickDetector", Handle)

function onClick()
Handle.Transparency=1
Door.Transparenc =1
wait(5)
Handle.Transparency=0
Door.Transparency 0
end
Clicker.MouseClick:connect(onClick()
--Hope it helps

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