Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

How to make a 1 Way Door?

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago
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.

0
Nothing happens, I put the script into the part with the name door, is there anything else I need to do? 1jumpingjack 0 — 10y
0
I don't know. RFYassine 15 — 10y
Ad

Answer this question