Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get the door to slide back?

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

✓ Accepted answer

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

1 comment

0

That worked, thanks. The smallest mistake makes the biggest difference lmao.

This discussion is preserved as it was. New answers, comments, and votes are closed.