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

How would I make the door stop moving?

So, I created this script that's supposed to open the door using a keycard and a keycard slider.

local open = false

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 then
					open = true
					repeat wait()
					door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame() * CFrame.new(0,0,0 + -0.1))
					until door.MovingPart.CFrame == Vector3.new(-21.429,7.775,6)
				end
			end
		end
	end
end)

The door just keeps on going, and won't stop at the designated point.

https://gyazo.com/130473033224178d1d98b845f14b9330

1 answer

✓ Accepted answer
local open = false

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 then
                    open = true
                    repeat wait()
for i = 1,60 do
wait(.1)
door.CFrame = door.CFrame * CFrame.new(0,0,0.1)
                end
            end
        end
    end
end)
end)

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