I need help because the script wont work if I cange it to on touch here it is with the click detector. It works with the click detector and I also have the other scripts/Models in it

open = false

wait(0.1)
script.Parent.Main.Anchored = true

function onClicked()
	if script.Parent.OPEND.Value == 1 then

		if open == false then
			script.Parent.Main.Anchored = false
			cfr = script.Parent.Main.CFrame
			open = true
			for i = 0,1.5,0.1 do
			wait(0.1)
			script.Parent.Main.CFrame = script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.1,0)*CFrame.new(0.01,0,-0.25)
			end
		script.Parent.Main.CFrame = cfr*CFrame.fromEulerAnglesXYZ(0,-math.pi/2,0)*CFrame.new(-2.5,0,-2.5)
		script.Parent.Main.Anchored = true
		open = false
		script.Parent.OPEND.Value = 0
		end
	elseif script.Parent.OPEND.Value == 0 then

		if open == false then
			script.Parent.Main.Anchored = false
			cfr = script.Parent.Main.CFrame
			open = true
			for i = 0,1.5,0.1 do
			wait(0.1)
			script.Parent.Main.CFrame = script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)*CFrame.new(-0.01,0,0.25)
			end
		script.Parent.Main.CFrame = cfr*CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)*CFrame.new(-2.5,0,2.5)
		script.Parent.Main.Anchored = true
		open = false
		script.Parent.OPEND.Value = 1
		end

	end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Here it is when I change it to a touch thingy

open = false

wait(0.1)
script.Parent.Main.Anchored = true

function onTouched(Hit)
	if script.Parent.OPEND.Value == 1 then

		if open == false then
			script.Parent.Main.Anchored = false
			cfr = script.Parent.Main.CFrame
			open = true
			for i = 0,1.5,0.1 do
			wait(0.1)
			script.Parent.Main.CFrame = script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.1,0)*CFrame.new(0.01,0,-0.25)
			end
		script.Parent.Main.CFrame = cfr*CFrame.fromEulerAnglesXYZ(0,-math.pi/2,0)*CFrame.new(-2.5,0,-2.5)
		script.Parent.Main.Anchored = true
		open = false
		script.Parent.OPEND.Value = 0
		end
	elseif script.Parent.OPEND.Value == 0 then

		if open == false then
			script.Parent.Main.Anchored = false
			cfr = script.Parent.Main.CFrame
			open = true
			for i = 0,1.5,0.1 do
			wait(0.1)
			script.Parent.Main.CFrame = script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)*CFrame.new(-0.01,0,0.25)
			end
		script.Parent.Main.CFrame = cfr*CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)*CFrame.new(-2.5,0,2.5)
		script.Parent.Main.Anchored = true
		open = false
		script.Parent.OPEND.Value = 1
		end

	end
end

script.Parent.Touched:connect(onTouched)

And if you need to know the weld script here it is also

function Weld(x,y)
	local W = Instance.new("Weld")
	W.Part0 = x
	W.Part1 = y
	local CJ = CFrame.new(x.Position)
	local C0 = x.CFrame:inverse()*CJ
	local C1 = y.CFrame:inverse()*CJ
	W.C0 = C0
	W.C1 = C1
	W.Parent = x
end

function Get(A)
	if A.className == "Part" then
		Weld(script.Parent.Main, A)
		A.Anchored = false
	else
		local C = A:GetChildren()
		for i=1, #C do
		Get(C[i])
		end
	end
end

function Finale()
	Get(script.Parent)
end

Finale()