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

How to make a 1 Way Door?

How do you make a one way door so it can only be opened from one side? I made a one way door that pushes players n a certain direction, but it is a bit faulty.

1 answer

door = script.Parent
function open()
door.Transparency = 0.5
door.Anchored = true
door.CanCollide = false
end
function close()
door.Transparency = 0
door.Anchored = false
door.CanCollide = true
end

reloading = false
function touched(hit) if hit~= nil then if hit.Parent~= nil then if game.Players:FindFirstChild(hit.Parent.Name)~= nil then if hit.Parent:FindFirstChild("Torso")~= nil then
	look = hit.Parent:FindFirstChild("Torso").Velocity.unit*10
	look2 = hit.Parent:FindFirstChild("Torso").CFrame.lookVector*10
	pt = (door.CFrame*CFrame.new(0, 0, -200000)).p -- waaay ahead in front
	dooroff = door.Position-look
	dooroff2 = door.Position-look2
	if ((pt-dooroff).magnitude<(pt-door.Position).magnitude and (pt - dooroff2).magnitude<(pt-door.Position).magnitude) then
		if reloading == false then
			open()
			reloading = true
			wait(1)
			close()
			reloading = false
		end
	else
		close() -- cant get past even if door is open!
	end
end end end end end

door.Touched:connect(touched)

If the door is touched from one part it becomes can collide, if it's from another nothing happens.

2 comments

0

Nothing happens, I put the script into the part with the name door, is there anything else I need to do?

0

I don't know.

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