Door Physics Script

robloxapp-20200306-2126373.wmv (1,7 MB)

Hi there.
I need help with the door. I want to make the door works when you click it and opens smoothly. I tried to make a script, but it didn’t work.

This is the script:

local bodythrust = script.Parent.BodyThrust
local clickdetector = script.Parent.ClickDetector

clickdetector.MouseClick:Connect(function()
if bodythrust.Force == Vector3.new(0, 0, 0)then
bodythrust.Force = Vector3.new(0, 0, -600)
clickdetector.MaxActivationDistance = 0
script.Parent.Anchored = false
wait(1.5)
clickdetector.MaxActivationDistance = 32
script.Parent.Anchored = true
else
bodythrust.Force = Vector3.new(0, 0, 0)
clickdetector.MaxActivationDistance = 0
script.Parent.Anchored = false
wait(1.5)
clickdetector.MaxActivationDistance = 32
script.Parent.Anchored = true
end
end)

I await your prompt responses. :slight_smile:

Thanks!

PD. I’m working on a new showcase!

1 Like

are you sure you want to use physics for this? i’m not discounting it for your solution but there’s a great CFrame tutorial on the documentation (scroll to rotating a door)

p.s. try putting your code inside this:

```lua
(copy + paste code here)
```

so it will look like this:

local x = 4
print("this is easier to read.")

If you open the Western template the doors there might help you understand. Also there are many doors in the toolbox with every kind of option imaginable including click to open. I recommend examining those scripts to learn more. You can learn from them but don’t have to use the free model. There are several ways to do this.