Script 1

local player = game.Players.LocalPlayer
local playergui = game.Players[player.Name].PlayerGui
local htp = playergui.Main.Main.HowToPlay
local main = playergui.Main.Main.Main



main.HowToPlay.MouseButton1Down:connect(function()
	while true do
		wait()
		htp.Visible = true
		main:TweenPosition(UDim2.new(0.4, 0, 0, -600))
		htp:TweenPosition(UDim2.new(0.4, 0, 0, 100))
		
		if main.Position == UDim2.new({0.4, 0},{0, -600}) then
			main.Visible = false
			break
		end
	end
end)

Script 2

local player = game.Players.LocalPlayer
local playergui = game.Players[player.Name].PlayerGui
local htp = playergui.Main.Main.HowToPlay
local main = playergui.Main.Main.Main

htp.Back.MouseButton1Down:connect(function()
	while true do
		wait()
		main.Visible = true
		main:TweenPosition(UDim2.new(0.4, 0, 0, 100))
		htp:TweenPosition(UDim2.new(0.4, 0, 0, 800))
		
		if htp.Position == UDim2.new({0.4, 0},{0, 800}) then
			htp.Visible = false
			break
		end
	end
end)

These are for 2 ScreenGui buttons, there are no errors but sometimes I am not able to click the buttons, then a few seconds later it works, and if I spam click it, it won't work, then it will just start switching a bunch of times when I am not clicking either buttons? Help? Thanks