So I know basic scripting. The thing is, I have 2 scripts. One of the opens and doesn't close, and the other doesn't move. How would I edit the following so that it closes after 2 seconds? Failing this, can you suggest a new script that works in this manner.
local Part = script.Parent
local newPos = Part.Position + Vector3.new(7,0,0)
local Time = 5
local Increment = 0.1
local Debounce = false
local Diff = newPos - Part.Position
local Mag = Diff.magnitude
local Direction = CFrame.new(Part.Position, newPos).lookVector
function MovePart()
if Debounce then return end
Debounce = true
for n = 0, Mag, Increment do
Part.CFrame = Part.CFrame + (Direction * Increment)
wait( (Time/Mag) * Increment )
end
Debounce = false
end
script.Parent.Touched:connect(MovePart)
Currently, when you first touch it, it moves to where I want it to. I don't know how to make it go back using the same form of algorithm
Thanks FaultyMatrix

4 comments
This works, but instead of going to the left into the wall, if comes forward towards myself, I have tried rotating but to no prevail. Any ideas?
It gets confusing rotating the part, the resizing everything (I've been through it too). The best thing is to completely shrink the door to size 1,1,1, and then rotate it until it's right. Then expand it back to normal.
Thanks, I got it right as soon as you posted that comment. Thank you so much for your help. :)
No problem! I would highly appreciate an upvote on my answer and a click of the "Accept Answer" button c: