Animated door problem

Hi! I got a script from toolbox and modified it and I am having some problems with… more info:

Video showing the problem

- YouTube

Explorer printscreen

image

Script
local Hinge = script.Parent.Parent.Parent.Hinge
local Open = false
local Debounce = false

script.Parent.MouseClick:Connect(function(Player)
	if Player.Backpack:FindFirstChild("Key") then
		if Debounce == false then 
			if Open == false then
				Open = true
				Debounce = true

				for i = 1, 26, 1 do
					script.Parent.Parent.Parent:SetPrimaryPartCFrame(script.Parent.Parent.Parent:GetPrimaryPartCFrame(Hinge.Position) * CFrame.Angles(0,math.rad(4),0,0) * CFrame.new(0,0,0))	
					wait()
				end
				Debounce = false
			elseif Open == true and Debounce == false then

				for i = 1, 26, 1 do
					script.Parent.Parent.Parent:SetPrimaryPartCFrame(script.Parent.Parent.Parent:GetPrimaryPartCFrame(Hinge.Position) * CFrame.Angles(0,math.rad(-4),0,0) * CFrame.new(0,0,0))	
					wait()
					Open = false
					Debounce = true
				end
				Debounce = false
			end
		end
	end
end)

Thanks :smiley:

You need to wait for the for i = loops to actually finish before they fire again.
Add a task.wait(3) or whatever works just ahead of your Debounce = false lines

Also you are setting Open to false and Debounce to true inside the second loop. They should be before the loop.

		        Open = false
				Debounce = true
				for i = 1, 26, 1 do
					script.Parent.Parent.Parent:SetPrimaryPartCFrame(script.Parent.Parent.Parent:GetPrimaryPartCFrame(Hinge.Position) * CFrame.Angles(0,math.rad(-4),0,0) * CFrame.new(0,0,0))	
					wait()
				end
				Debounce = false
                task.wait(3)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.