Function Door() loops for no reason (Solved)

My function for some reason just loops, like it prints Sound and Opening a bunch of times, so the whole function loops, and i only want the for loops to loop. What is the issue?

function Door(door,str,num)
	local function UpSide(str,num,num2)
		if str == "Side" then
			print("Side")
			for i=1,num do
				task.wait(0.01)
			end
		else
			print("Up")
			for i=1,num do
				task.wait(0.01)
				door.Door.Position += Vector3.new(0,num2,0)
			end
		end
	end
	
	local IsOpen = door.Door:GetAttribute("Open")
	door.Door.Click:Play()
	task.wait(0.1)
	print("Sound")
	if IsOpen == true then
		print("Opening")
		door.Door.Open:Play()
		ChangeDoorPrompts(door,false)
		Door(door,str,num,-0.1)
		door.Door:SetAttribute("Open",false)
		ChangeDoorActionText(door,"Open")
		ChangeDoorPrompts(door,true)
	else
		print("Closing")
		door.Door.Open:Play()
		ChangeDoorPrompts(door,false)
		Door(door,str,num,0.1)
		door.Door:SetAttribute("Open",true)
		ChangeDoorActionText(door,"Close")
		ChangeDoorPrompts(door,true)
	end
end```
1 Like

oh i forgot to say i dont call it using a loop

nvm sorry guys im stupid, i didnt see that i accidently called Door instead of UpSide

Just remove the topic, it doesn’t need to stay open. To remove your topic, go up to your orginal post, and then click the three dots, after that, click the trash can, and then confirm you want to delete this topic.