I'm trying to create a sliding glass door that activates when a player touches an invisible part near the door. While the script is having no problem detecting the player, it continues moving the door without halting. The script located in the transparent detector part:
I should note that the initial position is (-4.54, 8.27, -24.21), which is why I'm having it wait four seconds then move back to that position.
debounce = false
detector = script.Parent
ldoor = detector.Parent.leftDoor
script.Parent.Touched:connect(function(hit)
if debounce == false then
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
while ldoor.CFrame ~= Vector3.new(-10.54, 8.27, -24.21) do
wait()
ldoor.CFrame = ldoor.CFrame - Vector3.new(.1,0,0)
end
wait(4)
while ldoor.CFrame ~= Vector3.new(-4.54, 8.27, -24.21) do
wait()
ldoor.CFrame = ldoor.CFrame + Vector3.new(.1,0,0)
end
end
end
debounce = false
end)
Thank you for any and all help!

2 comments
Thank you! Perfect!
Glad I could help!