I'm working on an onTouched sliding door script, but for some reason when I touch the brick, the Door doesn't slide, it just teleports, and it doesn't teleport to where I want it to stop either. It disappears when I hit the brick.
function onTouched(hit)
debounce = false
player = hit.Parent
increment = 0.1
if hit.Parent ~= nil and debounce == false then
debounce = true
repeat
wait(0.01)
pos = 33.5
script.Parent.Parent.Door.CFrame = script.Parent.Parent.Door.CFrame * CFrame.new(86.222, pos - increment, 85.573)
pos = pos - increment
until
pos == 18.5
wait(3)
repeat
wait(0.01)
pos1 = 18.5
script.Parent.Parent.Door.CFrame = script.Parent.Parent.Door.CFrame * CFrame.new(86.222, pos1 + increment, 85.573)
pos1 = pos1 + increment
until
pos1 == 33.5
debounce = false
end
end
script.Parent.Touched:connect(onTouched)
