Need Help making a click brick into a gui button

I need help converting this script from working from a clickdetector into a gui button
at the momment the script below works from a clickdectecter inside a brick but I want it to work from a button in a gui

weld = false
welded = false

function touch(part)
	if part:IsA ("BasePart") then
		if weld == true then
			if welded == false then
				w = Instance.new("Weld")
				w.Part0,w.Part1 = script.Parent.Platform,part
				w.C0 = part.CFrame:toObjectSpace(script.Parent.Platform.CFrame):inverse()
				w.Parent = script.Parent.Platform
				
				welded = true
				
				
			end
		end
	end
end

function bttnClick()
	
	if weld == true then
		if welded == true then
			w:remove()
		end
		
		weld = false
		welded = false
		
		
	elseif weld == false then
		
		weld = true
		

		
	end
end

function childRemove(child)
	if child.ClassName == "Weld" then
		bttnClick()
		
	end
end
script.Parent.Platform.Touched:connect(touch)
script.Parent.Weld1.ClickDetector.MouseClick:connect(bttnClick)
script.Parent.Platform.ChildRemoved:connect(childRemove)

Just use MouseButton1Click on the gui button.

script.Parent.TextButton.MouseButton1Click:Connect(bttnClick)

Do as the person above suggested, or make a GUI that looks like a brick, and once again do as the person above suggested. You cannot use ClickDetectors’ MouseClick in PlayerGui, pretty sure.

Also, it’s good practice to use :Connect(), rather than :connect().