Game Detects Player Clicking on Button Even Though They are Clicking Somewhere Else

I want it to so when the LocalPlayer clicks on a button, a script detects if a BoolValue is true and if it is then the player transforms (fires a remote)

The problem is that even if the player clicks somewhere else the script detects the player clicking.

game.ReplicatedStorage.InRound.Changed:Connect(function()
	if game.ReplicatedStorage.InRound.Value == true then
		if game.Players.LocalPlayer.PlayerGui.IsMonster.Value == true then
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel1.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel2.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Enabled = true
			wait(25)
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.Visible = false
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel.Visible = false
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel1.Visible = false
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel2.Visible = false
		else
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel1.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel2.Visible = true
			game.Players.LocalPlayer.PlayerGui.MonsterGui.Enabled = false
		end
	else
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.Visible = true
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel.Visible = true
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel1.Visible = true
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel2.Visible = true
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Enabled = false
	end
end)

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input)
	if game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.Visible and input.UserInputType == Enum.UserInputType.MouseButton1 and game.Players.LocalPlayer.PlayerGui.MonsterGui.Enabled then
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.Visible = false
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel.Visible = false
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel1.Visible = false
		game.Players.LocalPlayer.PlayerGui.MonsterGui.Popup.TextLabel2.Visible = false
	end
end)

local Hotkey = "T"

UserInputService.InputBegan:Connect(function(InputObject, GameProcessedEvent)
if GameProcessedEvent then return end
	if InputObject.KeyCode == Enum.KeyCode[Hotkey] or InputObject.UserInputType == Enum.UserInputType.MouseButton1 then
		if game.ReplicatedStorage.InRound.Value == true then
			game.ReplicatedStorage.MonsterTransform:FireServer(game.Players.LocalPlayer)
			print("wants to transform")
		end
	end
end)

local imageButton = game.Players.LocalPlayer.PlayerGui.MonsterGui.Transform

local function onPressed()
	print("clicked")
	if game.ReplicatedStorage.InRound.Value == true then
		game.ReplicatedStorage.MonsterTransform:FireServer(game.Players.LocalPlayer)
		print("wants to transform")
	end
end

imageButton.MouseButton1Down:Connect(onPressed)

This line was the problem because of the or InputObject.UserInputType == Enum.UserInputType.MouseButton1 then