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

How do I get the door to slide back?

Asked by 4 years ago

Someone helped me with getting the door to slide open and STOP at an exact position, now I can't get the door to slide back and stop, it just teleports there instead of sliding.

Script

local open = false
local debounce = true
local beep = script.Parent.Beep

script.Parent.Touched:Connect(function(hit)
    if hit:IsA("Part") then
        if hit.Name == "Handle" then
            if hit.Parent.Name == "Keycard" then
                local door = script.Parent.Parent.Parent.Parent.CDDoor.Door
                if open == false and debounce == true then
                    beep:Play()
                    open = true
                    debounce = false
                    for i = 1,53 do
                        wait()
                        door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame() * CFrame.new(0,0,-0.1))
                    end
                    wait(2)
                    debounce = true
                elseif open == true and debounce == true then
                    beep:Play()
                    open = false
                    debounce = false
                    for i = -1,53 do
                        door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame() * CFrame.new(0,0,0.1))
                    end
                    wait(2)
                    debounce = true
                end
            end
        end
    end
end)

What happens https://gyazo.com/c48abb017f1d72e88476d6334dc8c62e

1 answer

Log in to vote
0
Answered by 4 years ago

i found your mistake at line 24-26 you don't have a wait in between the i loop at line 24. So all you would need is a wait() inside the loop

0
That worked, thanks. The smallest mistake makes the biggest difference lmao. killerbrenden 1537 — 4y
Ad

Answer this question